New submission from kernc:

ConfigParser does not handle files that specify options in the "global" section 
(first option specified before any section is). This configuration "behavior" 
is present in the configuration files in the wild [1, 2], and while the naive 
workaround is simple, ... really?!

The support for section-less configuration would also play nice with various 
"POSIX-compatible config files" (think /etc/default/*, /etc/os-release, ...).

Ideally, the support could be enabled by default or only when `strict=False` 
constructor argument is supplied. The options in this global section could 
likely be accessed in the empty ('') section, e.g. `config.get('', 'option')`.

Thus, ConfigParser could finally really replace the venerable ConfigObj [3].

[1]: http://stackoverflow.com/a/22501121/
[2]: 
https://www.google.com/search?q=MissingSectionHeaderError%3A+File+contains+no+section+headers
[3]: http://www.voidspace.org.uk/python/configobj.html

----------
components: Library (Lib)
messages: 225693
nosy: kernc
priority: normal
severity: normal
status: open
title: ConfigParser does not handle files without sections
type: behavior
versions: Python 2.7, Python 3.2, Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22253>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to