Inada Naoki <[email protected]> added the comment:
It seems twice call of `optionxform` is not avoidable when read-and-write
workflow.
I'm not against about fixing readdict.
But I don't think configparser supports non-idempotent optionxform.
>>> import configparser
>>> cfg = configparser.ConfigParser()
>>> cfg.optionxform = lambda s: "#"+s
>>> cfg.add_section("sec")
>>> cfg.set("sec", "foo", "1")
>>> cfg["sec2"] = cfg["sec"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/inada-n/work/python/cpython/Lib/configparser.py", line 974, in
__setitem__
self.read_dict({key: value})
File "/Users/inada-n/work/python/cpython/Lib/configparser.py", line 747, in
read_dict
for key, value in keys.items():
File "/Users/inada-n/work/python/cpython/Lib/_collections_abc.py", line 744,
in __iter__
yield (key, self._mapping[key])
File "/Users/inada-n/work/python/cpython/Lib/configparser.py", line 1254, in
__getitem__
raise KeyError(key)
KeyError: '#foo'
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35838>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com