Issue 854484: ConfigParser should raise an error for duplicate options (original) (raw)

Created on 2003-12-05 01:24 by mceahm, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ConfigParser_DuplicateOptionError.patch mceahm,2003-12-05 01:24 Patch to ConfigParser.py and its test (test_cfgparser.py)
Messages (4)
msg45021 - (view) Author: Mark McEahern (mceahm) Date: 2003-12-05 01:24
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.
msg45022 - (view) Author: Tony Meyer (anadelonbrin) Date: 2003-12-09 02:16
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.
msg45023 - (view) Author: Mark McEahern (mceahm) Date: 2003-12-14 16:25
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
msg45024 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2004-05-18 00:45
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.
History
Date User Action Args
2022-04-11 14:56:01 admin set github: 39665
2003-12-05 01:24:48 mceahm create