New submission from Mark Lonnemann :
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
<https://bugs.python.org/issue46770>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com