This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author malonn
Recipients malonn
Date 2022-02-16.17:17:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645031843.76.0.82823546709.issue46770@roundup.psfhosted.org>
In-reply-to
Content
ConfigParser() is not using a custom dictionary class correctly, according to my understanding.  I have duplicate options in a config file that I want to rename uniquely.  The following code does not work.
x = 0
class MultiDict(dict):
    def __setitem__(self, key, value):
        if key == 'textsize':
            global x
            key += str(x)
            x += 1
        dict.__setitem__(self, key, value)

...

config1 = cp.ConfigParser(dict_type=MultiDict)
config1.read('ini_file.ini')

"textsize" is the option named twice in my config file.  When I run the code, I get a DuplicateOptionError for "textsize".  No one seems to know how to solve this, so it could be a bug.  If it's sloppy coding, I apoligize.
History
Date User Action Args
2022-02-16 17:17:23malonnsetrecipients: + malonn
2022-02-16 17:17:23malonnsetmessageid: <1645031843.76.0.82823546709.issue46770@roundup.psfhosted.org>
2022-02-16 17:17:23malonnlinkissue46770 messages
2022-02-16 17:17:23malonncreate