mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
bpo-38741: Definition of multiple ']' in header configparser (GH-17129) (#27110)
Co-authored-by: Jason Killen <jason.killen@windsorcircle.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
(cherry picked from commit 2924bb1a56
)
Co-authored-by: jsnklln <jsnklln@gmail.com>
This commit is contained in:
parent
f514addfbc
commit
1cc6769e41
3 changed files with 9 additions and 1 deletions
|
@ -563,7 +563,7 @@ class RawConfigParser(MutableMapping):
|
||||||
# Regular expressions for parsing section headers and options
|
# Regular expressions for parsing section headers and options
|
||||||
_SECT_TMPL = r"""
|
_SECT_TMPL = r"""
|
||||||
\[ # [
|
\[ # [
|
||||||
(?P<header>[^]]+) # very permissive!
|
(?P<header>.+) # very permissive!
|
||||||
\] # ]
|
\] # ]
|
||||||
"""
|
"""
|
||||||
_OPT_TMPL = r"""
|
_OPT_TMPL = r"""
|
||||||
|
|
|
@ -79,6 +79,7 @@ class BasicTestCase(CfgParserTestCaseClass):
|
||||||
'Spacey Bar',
|
'Spacey Bar',
|
||||||
'Spacey Bar From The Beginning',
|
'Spacey Bar From The Beginning',
|
||||||
'Types',
|
'Types',
|
||||||
|
'This One Has A ] In It',
|
||||||
]
|
]
|
||||||
|
|
||||||
if self.allow_no_value:
|
if self.allow_no_value:
|
||||||
|
@ -130,6 +131,7 @@ class BasicTestCase(CfgParserTestCaseClass):
|
||||||
eq(cf.get('Types', 'float'), "0.44")
|
eq(cf.get('Types', 'float'), "0.44")
|
||||||
eq(cf.getboolean('Types', 'boolean'), False)
|
eq(cf.getboolean('Types', 'boolean'), False)
|
||||||
eq(cf.get('Types', '123'), 'strange but acceptable')
|
eq(cf.get('Types', '123'), 'strange but acceptable')
|
||||||
|
eq(cf.get('This One Has A ] In It', 'forks'), 'spoons')
|
||||||
if self.allow_no_value:
|
if self.allow_no_value:
|
||||||
eq(cf.get('NoValue', 'option-without-value'), None)
|
eq(cf.get('NoValue', 'option-without-value'), None)
|
||||||
|
|
||||||
|
@ -320,6 +322,8 @@ int {0[1]} 42
|
||||||
float {0[0]} 0.44
|
float {0[0]} 0.44
|
||||||
boolean {0[0]} NO
|
boolean {0[0]} NO
|
||||||
123 {0[1]} strange but acceptable
|
123 {0[1]} strange but acceptable
|
||||||
|
[This One Has A ] In It]
|
||||||
|
forks {0[0]} spoons
|
||||||
""".format(self.delimiters, self.comment_prefixes)
|
""".format(self.delimiters, self.comment_prefixes)
|
||||||
if self.allow_no_value:
|
if self.allow_no_value:
|
||||||
config_string += (
|
config_string += (
|
||||||
|
@ -394,6 +398,9 @@ boolean {0[0]} NO
|
||||||
"boolean": False,
|
"boolean": False,
|
||||||
123: "strange but acceptable",
|
123: "strange but acceptable",
|
||||||
},
|
},
|
||||||
|
"This One Has A ] In It": {
|
||||||
|
"forks": "spoons"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
if self.allow_no_value:
|
if self.allow_no_value:
|
||||||
config.update({
|
config.update({
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
:mod:`configparser`: using ']' inside a section header will no longer cut the section name short at the ']'
|
Loading…
Add table
Add a link
Reference in a new issue