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:
Prince Roshan 2024-03-06 19:35:54 +05:30 committed by GitHub
parent 27858e2a17
commit e800265aa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 55 additions and 0 deletions

View file

@ -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."""