Skip to content

Commit 924a3bf

Browse files
authored
gh-93573: Replace wrong example domains in configparser doc (GH-93574)
* Replace bitbucket.org domain by forge.example * Update example to python.org * Use explicitly invalid domain topsecret.server.com domain is not controled by PSF. It's replaced by invalid topsecret.server.example domain. It follows RFC 2606, which advise .example as TLD for documentation.
1 parent 739c026 commit 924a3bf

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

Doc/library/configparser.rst

+23-23
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ Let's take a very basic configuration file that looks like this:
6969
CompressionLevel = 9
7070
ForwardX11 = yes
7171
72-
[bitbucket.org]
72+
[forge.example]
7373
User = hg
7474
75-
[topsecret.server.com]
75+
[topsecret.server.example]
7676
Port = 50022
7777
ForwardX11 = no
7878
@@ -89,10 +89,10 @@ creating the above configuration file programmatically.
8989
>>> config['DEFAULT'] = {'ServerAliveInterval': '45',
9090
... 'Compression': 'yes',
9191
... 'CompressionLevel': '9'}
92-
>>> config['bitbucket.org'] = {}
93-
>>> config['bitbucket.org']['User'] = 'hg'
94-
>>> config['topsecret.server.com'] = {}
95-
>>> topsecret = config['topsecret.server.com']
92+
>>> config['forge.example'] = {}
93+
>>> config['forge.example']['User'] = 'hg'
94+
>>> config['topsecret.server.example'] = {}
95+
>>> topsecret = config['topsecret.server.example']
9696
>>> topsecret['Port'] = '50022' # mutates the parser
9797
>>> topsecret['ForwardX11'] = 'no' # same here
9898
>>> config['DEFAULT']['ForwardX11'] = 'yes'
@@ -115,28 +115,28 @@ back and explore the data it holds.
115115
>>> config.read('example.ini')
116116
['example.ini']
117117
>>> config.sections()
118-
['bitbucket.org', 'topsecret.server.com']
119-
>>> 'bitbucket.org' in config
118+
['forge.example', 'topsecret.server.example']
119+
>>> 'forge.example' in config
120120
True
121-
>>> 'bytebong.com' in config
121+
>>> 'python.org' in config
122122
False
123-
>>> config['bitbucket.org']['User']
123+
>>> config['forge.example']['User']
124124
'hg'
125125
>>> config['DEFAULT']['Compression']
126126
'yes'
127-
>>> topsecret = config['topsecret.server.com']
127+
>>> topsecret = config['topsecret.server.example']
128128
>>> topsecret['ForwardX11']
129129
'no'
130130
>>> topsecret['Port']
131131
'50022'
132-
>>> for key in config['bitbucket.org']: # doctest: +SKIP
132+
>>> for key in config['forge.example']: # doctest: +SKIP
133133
... print(key)
134134
user
135135
compressionlevel
136136
serveraliveinterval
137137
compression
138138
forwardx11
139-
>>> config['bitbucket.org']['ForwardX11']
139+
>>> config['forge.example']['ForwardX11']
140140
'yes'
141141

142142
As we can see above, the API is pretty straightforward. The only bit of magic
@@ -154,15 +154,15 @@ configuration while the previously existing keys are retained.
154154
>>> another_config = configparser.ConfigParser()
155155
>>> another_config.read('example.ini')
156156
['example.ini']
157-
>>> another_config['topsecret.server.com']['Port']
157+
>>> another_config['topsecret.server.example']['Port']
158158
'50022'
159-
>>> another_config.read_string("[topsecret.server.com]\nPort=48484")
160-
>>> another_config['topsecret.server.com']['Port']
159+
>>> another_config.read_string("[topsecret.server.example]\nPort=48484")
160+
>>> another_config['topsecret.server.example']['Port']
161161
'48484'
162-
>>> another_config.read_dict({"topsecret.server.com": {"Port": 21212}})
163-
>>> another_config['topsecret.server.com']['Port']
162+
>>> another_config.read_dict({"topsecret.server.example": {"Port": 21212}})
163+
>>> another_config['topsecret.server.example']['Port']
164164
'21212'
165-
>>> another_config['topsecret.server.com']['ForwardX11']
165+
>>> another_config['topsecret.server.example']['ForwardX11']
166166
'no'
167167

168168
This behaviour is equivalent to a :meth:`ConfigParser.read` call with several
@@ -195,9 +195,9 @@ recognizes Boolean values from ``'yes'``/``'no'``, ``'on'``/``'off'``,
195195

196196
>>> topsecret.getboolean('ForwardX11')
197197
False
198-
>>> config['bitbucket.org'].getboolean('ForwardX11')
198+
>>> config['forge.example'].getboolean('ForwardX11')
199199
True
200-
>>> config.getboolean('bitbucket.org', 'Compression')
200+
>>> config.getboolean('forge.example', 'Compression')
201201
True
202202

203203
Apart from :meth:`~ConfigParser.getboolean`, config parsers also
@@ -224,7 +224,7 @@ provide fallback values:
224224
Please note that default values have precedence over fallback values.
225225
For instance, in our example the ``'CompressionLevel'`` key was
226226
specified only in the ``'DEFAULT'`` section. If we try to get it from
227-
the section ``'topsecret.server.com'``, we will always get the default,
227+
the section ``'topsecret.server.example'``, we will always get the default,
228228
even if we specify a fallback:
229229

230230
.. doctest::
@@ -239,7 +239,7 @@ the ``fallback`` keyword-only argument:
239239

240240
.. doctest::
241241

242-
>>> config.get('bitbucket.org', 'monster',
242+
>>> config.get('forge.example', 'monster',
243243
... fallback='No such things as monsters')
244244
'No such things as monsters'
245245

0 commit comments

Comments
 (0)