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.
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.
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
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.