ConfigParser: Bug or feature?

Gerhard Häring gh at ghaering.de
Wed Mar 5 15:45:48 EST 2003


Thor Arne Johansen wrote:
> 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??

I'd consider it a bug. You might want to submit your patch:

http://python.org/patches/

-- Gerhard




More information about the Python-list mailing list