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

SourceForge.net noreply at sourceforge.net
Mon May 17 20:45:19 EDT 2004


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

Category: Library (Lib)
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Mark McEahern (mceahm)
Assigned to: Fred L. Drake, Jr. (fdrake)
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: Fred L. Drake, Jr. (fdrake)
Date: 2004-05-17 20:45

Message:
Logged In: YES 
user_id=3066

It's not at all clear what "should" happen when a single
sets an option more than once.  Given that, a change in
semantics is undesirable, especially since existing
applications can easily depend on the existing behavior
without any specific intention, so changing it is dangerous
(the user supplies a configuration, things work, upgrades
Python, things break).

Rejecting as not backward compatible.

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

Comment By: Mark McEahern (mceahm)
Date: 2003-12-14 11: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 21: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