Not planned
Description
Bug report
Bug description:
Code snippet:
parser = configparser.ConfigParser()
ini_file = '/home/philipp/.local/share/Steam/steamapps/compatdata/244210/pfx/drive_c/users/steamuser/Documents/Assetto Corsa/cfg/extension/state/lua/app/CspDebug.ini'
parser.read(ini_file)
Error:
File "/mnt/sda1/Programming/accm/libjam/notebook.py", line 58, in read_ini
parser.read(ini_file)
~~~~~~~~~~~^^^^^^^^^^
File "/usr/lib64/python3.13/configparser.py", line 735, in read
self._read(fp, filename)
~~~~~~~~~~^^^^^^^^^^^^^^
File "/usr/lib64/python3.13/configparser.py", line 1050, in _read
ParsingError._raise_all(self._read_inner(fp, fpname))
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.13/configparser.py", line 334, in _raise_all
raise next(exceptions).combine(exceptions)
configparser.ParsingError: Source contains parsing errors: '/home/philipp/.local/share/Steam/steamapps/compatdata/244210/pfx/drive_c/users/steamuser/Documents/Assetto Corsa/cfg/extension/state/lua/app/CspDebug.ini'
[line 9]: "}'\n"
Contents of ini_file:
[STRING]
12866846752895976527='{
distance = 100,
count = 10,
dirty = false,
flags = { bsphere = false, bbox = true, outline = true, text = true },
filter = "?",
active = false
}'
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Activity
Zheaoli commentedon May 22, 2025
I think this is not a bug, This is not a regular ini config file.
Actually, we don't have a RFC for ini config file. So the behavior will depend on the developer. On my test, the developer don't support this grammar in the ini parse lib in other programming like Go, Java at the same time.
cc @picnixz
picnixz commentedon May 23, 2025
The problem is the handling of multiline values. Multiline values are handled according to their indentation, namely:
is actually equivalent to declare a field
12866846752895976527
which expands until active = False and then a new field}'
which in this case has no value, so is not a valid key.The solution, I think, would be the following:
Note that in this case, the content of 12866846752895976527 would be '{...}', with
'
included.So indeed, it is not an error with configparser, but an error in how the content of the INI file is written.
PhilippKosarev commentedon May 23, 2025
Yeah, the issue does seem to be in the INI fille itself, and adding an indentation before
}'
does fix the error.Thank you for the thorough explanation :)