[Patches] [ python-Patches-854484 ] ConfigParser should raise an error for duplicate options

SourceForge.net noreply at sourceforge.net
Sun Dec 14 11:25:28 EST 2003


Patches item #854484, was opened at 2003-12-04 19:24
Message generated for change (Comment added) made by mceahm
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=854484&group_id=5470

Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mark McEahern (mceahm)
Assigned to: Nobody/Anonymous (nobody)
Summary: ConfigParser should raise an error for duplicate options

Initial Comment:
ConfigParser should raise an error for duplicate
options within a section; e.g.,

  [test]
  key=value1
  key=value2

but currently, it silently adds only one of the
duplicate options to the section (since options are
stored in a dictionary, keyed by option name).

Suggested checkin comments:

* Added an Error for DuplicateOptionError.

* Modified _readfp() to raise DuplicateOptionError when
a duplicate option is found within a section.

* Added a test case to verify that the error is raised.


----------------------------------------------------------------------

>Comment By: Mark McEahern (mceahm)
Date: 2003-12-14 10:25

Message:
Logged In: YES 
user_id=150272

I hadn't considered multiple files being read into the
ConfigParser instance.

It seems like there's three potential uses:

* Duplicate options should override previous settings.

* Duplicate options should result in an array of values for
that setting.

* Duplicate options should be considered an error.

The scope of the problem is larger than I thought.

Thanks for your comments.

Cheers,

// m

----------------------------------------------------------------------

Comment By: Tony Meyer (anadelonbrin)
Date: 2003-12-08 20:16

Message:
Logged In: YES 
user_id=552329

Definately -1 here.

Firstly, a duplicate option isn't fatal, so if there is an 
error at all, it should be treated like other non-fatal 
(i.e. parsing) errors and be raised only at the end.

Secondly, there's no reason why a duplicate option is 
invalid.  In particular, when working with multiple config 
files, it's desireable to be able to have later files 
override earlier ones.  This might not apply so much to 
single files, but to be consistent, should.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=854484&group_id=5470



More information about the Patches mailing list