[New-bugs-announce] [issue46770] ConfigParser(dict_type=) not behaving as expected
Mark Lonnemann
report at bugs.python.org
Wed Feb 16 12:17:23 EST 2022
New submission from Mark Lonnemann <mlonnemann at msn.com>:
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.
----------
components: Extension Modules
messages: 413343
nosy: malonn
priority: normal
severity: normal
status: open
title: ConfigParser(dict_type=) not behaving as expected
type: behavior
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46770>
_______________________________________
More information about the New-bugs-announce
mailing list