Skip to content

Commit 4d74bb4

Browse files
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. (cherry picked from commit 924a3bf) Co-authored-by: sblondon <[email protected]>
1 parent bc3718e commit 4d74bb4

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
@@ -65,10 +65,10 @@ Let's take a very basic configuration file that looks like this:
6565
CompressionLevel = 9
6666
ForwardX11 = yes
6767
68-
[bitbucket.org]
68+
[forge.example]
6969
User = hg
7070
71-
[topsecret.server.com]
71+
[topsecret.server.example]
7272
Port = 50022
7373
ForwardX11 = no
7474
@@ -85,10 +85,10 @@ creating the above configuration file programmatically.
8585
>>> config['DEFAULT'] = {'ServerAliveInterval': '45',
8686
... 'Compression': 'yes',
8787
... 'CompressionLevel': '9'}
88-
>>> config['bitbucket.org'] = {}
89-
>>> config['bitbucket.org']['User'] = 'hg'
90-
>>> config['topsecret.server.com'] = {}
91-
>>> topsecret = config['topsecret.server.com']
88+
>>> config['forge.example'] = {}
89+
>>> config['forge.example']['User'] = 'hg'
90+
>>> config['topsecret.server.example'] = {}
91+
>>> topsecret = config['topsecret.server.example']
9292
>>> topsecret['Port'] = '50022' # mutates the parser
9393
>>> topsecret['ForwardX11'] = 'no' # same here
9494
>>> config['DEFAULT']['ForwardX11'] = 'yes'
@@ -111,28 +111,28 @@ back and explore the data it holds.
111111
>>> config.read('example.ini')
112112
['example.ini']
113113
>>> config.sections()
114-
['bitbucket.org', 'topsecret.server.com']
115-
>>> 'bitbucket.org' in config
114+
['forge.example', 'topsecret.server.example']
115+
>>> 'forge.example' in config
116116
True
117-
>>> 'bytebong.com' in config
117+
>>> 'python.org' in config
118118
False
119-
>>> config['bitbucket.org']['User']
119+
>>> config['forge.example']['User']
120120
'hg'
121121
>>> config['DEFAULT']['Compression']
122122
'yes'
123-
>>> topsecret = config['topsecret.server.com']
123+
>>> topsecret = config['topsecret.server.example']
124124
>>> topsecret['ForwardX11']
125125
'no'
126126
>>> topsecret['Port']
127127
'50022'
128-
>>> for key in config['bitbucket.org']: # doctest: +SKIP
128+
>>> for key in config['forge.example']: # doctest: +SKIP
129129
... print(key)
130130
user
131131
compressionlevel
132132
serveraliveinterval
133133
compression
134134
forwardx11
135-
>>> config['bitbucket.org']['ForwardX11']
135+
>>> config['forge.example']['ForwardX11']
136136
'yes'
137137

138138
As we can see above, the API is pretty straightforward. The only bit of magic
@@ -150,15 +150,15 @@ configuration while the previously existing keys are retained.
150150
>>> another_config = configparser.ConfigParser()
151151
>>> another_config.read('example.ini')
152152
['example.ini']
153-
>>> another_config['topsecret.server.com']['Port']
153+
>>> another_config['topsecret.server.example']['Port']
154154
'50022'
155-
>>> another_config.read_string("[topsecret.server.com]\nPort=48484")
156-
>>> another_config['topsecret.server.com']['Port']
155+
>>> another_config.read_string("[topsecret.server.example]\nPort=48484")
156+
>>> another_config['topsecret.server.example']['Port']
157157
'48484'
158-
>>> another_config.read_dict({"topsecret.server.com": {"Port": 21212}})
159-
>>> another_config['topsecret.server.com']['Port']
158+
>>> another_config.read_dict({"topsecret.server.example": {"Port": 21212}})
159+
>>> another_config['topsecret.server.example']['Port']
160160
'21212'
161-
>>> another_config['topsecret.server.com']['ForwardX11']
161+
>>> another_config['topsecret.server.example']['ForwardX11']
162162
'no'
163163

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

192192
>>> topsecret.getboolean('ForwardX11')
193193
False
194-
>>> config['bitbucket.org'].getboolean('ForwardX11')
194+
>>> config['forge.example'].getboolean('ForwardX11')
195195
True
196-
>>> config.getboolean('bitbucket.org', 'Compression')
196+
>>> config.getboolean('forge.example', 'Compression')
197197
True
198198

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

226226
.. doctest::
@@ -235,7 +235,7 @@ the ``fallback`` keyword-only argument:
235235

236236
.. doctest::
237237

238-
>>> config.get('bitbucket.org', 'monster',
238+
>>> config.get('forge.example', 'monster',
239239
... fallback='No such things as monsters')
240240
'No such things as monsters'
241241

0 commit comments

Comments
 (0)