mirror of
https://github.com/python/cpython.git
synced 2025-10-28 04:04:44 +00:00
gh-107625: configparser: Raise error if a missing value is continued (GH-107651)
Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
This commit is contained in:
parent
27858e2a17
commit
e800265aa1
4 changed files with 55 additions and 0 deletions
|
|
@ -1555,6 +1555,30 @@ def test_source_as_bytes(self):
|
|||
"'[badbad'"
|
||||
)
|
||||
|
||||
def test_keys_without_value_with_extra_whitespace(self):
|
||||
lines = [
|
||||
'[SECT]\n',
|
||||
'KEY1\n',
|
||||
' KEY2 = VAL2\n', # note the Space before the key!
|
||||
]
|
||||
parser = configparser.ConfigParser(
|
||||
comment_prefixes="",
|
||||
allow_no_value=True,
|
||||
strict=False,
|
||||
delimiters=('=',),
|
||||
interpolation=None,
|
||||
)
|
||||
with self.assertRaises(configparser.MultilineContinuationError) as dse:
|
||||
parser.read_file(lines)
|
||||
self.assertEqual(
|
||||
str(dse.exception),
|
||||
"Key without value continued with an indented line.\n"
|
||||
"file: '<???>', line: 3\n"
|
||||
"' KEY2 = VAL2\\n'"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
class CoverageOneHundredTestCase(unittest.TestCase):
|
||||
"""Covers edge cases in the codebase."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue