Open
Description
Bug report
A clear and concise description of what the bug is.
Include a minimal, reproducible example (https://stackoverflow.com/help/minimal-reproducible-example), if possible.
Your environment
- CPython versions tested on: 3.11.0b5
- Operating system and architecture: x86_64
here is a simple example:
>>> import configparser
>>> cfg = configparser.ConfigParser()
>>> cfg.read_string('[foo]\nx = 1\n...\n')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.11/configparser.py", line 738, in read_string
self.read_file(sfile, source)
File "/usr/lib/python3.11/configparser.py", line 733, in read_file
self._read(f, source)
File "/usr/lib/python3.11/configparser.py", line 1131, in _read
raise e
configparser.ParsingError: Source contains parsing errors: '<string>'
[line 3]: '...\n'
>>> cfg['foo']['x']
'1'
I expect reading to be an all-or-nothing operation -- if the file contains a syntax error it shouldn't modify the ConfigParser
object with half of the file's contents