ConfigParser: Bug or feature?

Thor Arne Johansen thorj at ibas.no
Tue Mar 4 20:28:41 EST 2003


Quick question about the ConfigParser module:

It raises an exception when you try to insert an already existing section
(which is good).

However when parsing an external file (.read() or .readfp()) with multiple
defined sections it silently ignores all but the last one encountered.

I looked at the source, and identified where this is happening, and it
appears this behavior is by design?

I modified the code to raise an DuplicateSectionError exception, and it
gives the expected behavior (?).

The docs say:

"""
exception DuplicateSectionError
Exception raised when multiple sections with the same name are found, or if
add_section() is called with the name of a section that is already present.
"""

I'm using Python 2.2.2 on linux, but I've verified the same behavior on
2.2.1 (win98 and linux)

Is this a bug or a feature??







More information about the Python-list mailing list