Message 226827 - Python tracker (original) (raw)

I am dubious that there are any with a mixture of both sections and additional option lines at the top without a section.

rsyncd.conf [1] is one such example, and I wouldn't say there aren't countless more in the wild.

Anyone writing an app and planning to parse a .ini file can add [Start] or [Setup] at the top.

Indeed. Here lies the problem of this unfortunate issue: MissingSectionHeaderError is only ever caught [9] to mitigate this awful default behavior and attach a dummy section at the top, as you say. Or can anyone care to propose another relevant use case for this poorly (un-) thought through exception?

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

While this is very much off-topic, configobj [3] does too seem to have done so since ages.