[issue22253] ConfigParser does not handle files without sections

Terry J. Reedy report at bugs.python.org
Tue Sep 9 06:29:42 CEST 2014


Terry J. Reedy added the comment:

The MS function GetPrivateProfileString appears to require sections.
http://msdn.microsoft.com/en-us/library/ms724353.aspx
On the other hand, it does not appear to do interpolation, so we have already not restricted ourselves to the MS function.

In looking through the .ini files in my game directory, which includes some old games, I found a couple with no section header.  So such files do exist in the wild.  I am dubious that there are any with a mixture of both sections and additional option lines at the top without a section.

Anyone writing an app and planning to parse a .ini file can add [Start] or [Setup] at the top.  So there is only an issue for 3rd party software parsing a file without.

I think a more useful new configparser feature would be to keep comment lines and write them back out after a configuration is changed.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22253>
_______________________________________


More information about the Python-bugs-list mailing list