[issue46770] ConfigParser(dict_type=) not behaving as expected

2022-02-17 Thread Mark Lonnemann


Mark Lonnemann  added the comment:

I know, thanks though.  I just thought there was a way to do it via dict_type=. 
 I've read it can be done, but is complex.  I've yet to see any examples of how.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46770] ConfigParser(dict_type=) not behaving as expected

2022-02-17 Thread Cyril Jouve


Cyril Jouve  added the comment:

you need to pass `strict=False` to ConfigParser :


When `strict` is True, the parser won't allow for any section or option
duplicates while reading from a single source (file, string or
dictionary). Default is True.

--
nosy: +Cyril Jouve

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46770] ConfigParser(dict_type=) not behaving as expected

2022-02-16 Thread Mark Lonnemann


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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com