10000 [3.10] bpo-38741: Definition of multiple ']' in header configparser (GH-17129) by miss-islington · Pull Request #27110 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.10] bpo-38741: Definition of multiple ']' in header configparser (GH-17129) #27110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-38741: Definition of multiple ']' in header configparser (GH-17129)
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 2924bb1)

Co-authored-by: jsnklln <jsnklln@gmail.com>
  • Loading branch information
jsnklln authored and miss-islington committed Jul 13, 2021
commit 7e2f31c6044944d7398f168713440fcd0122a6fb
2 changes: 1 addition & 1 deletion Lib/configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ class RawConfigParser(MutableMapping):
# Regular expressions for parsing section headers and options
_SECT_TMPL = r"""
\[ # [
(?P<header>[^]]+) # very permissive!
(?P<header>.+) # very permissive!
\] # ]
"""
_OPT_TMPL = r"""
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def basic_test(self, cf):
'Spacey Bar',
'Spacey Bar From The Beginning',
'Types',
'This One Has A ] In It',
]

if self.allow_no_value:
Expand Down Expand Up @@ -130,6 +131,7 @@ def basic_test(self, cf):
eq(cf.get('Types', 'float'), "0.44")
eq(cf.getboolean('Types', 'boolean'), False)
eq(cf.get('Types', '123'), 'strange but acceptable')
eq(cf.get('This One Has A ] In It', 'forks'), 'spoons')
if self.allow_no_value:
eq(cf.get('NoValue', 'option-without-value'), None)

Expand Down Expand Up @@ -320,6 +322,8 @@ def test_basic(self):
float {0[0]} 0.44
boolean {0[0]} NO
123 {0[1]} strange but acceptable
[This One Has A ] In It]
forks {0[0]} spoons
""".format(self.delimiters, self.comment_prefixes)
if self.allow_no_value:
config_string += (
Expand Down Expand Up @@ -394,6 +398,9 @@ def test_basic_from_dict(self):
"boolean": False,
123: "strange but acceptable",
},
"This One Has A ] In It": {
"forks": "spoons"
},
}
if self.allow_no_value:
config.update({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:mod:`configparser`: using ']' inside a section header will no longer cut the section name short at the ']'
0