bpo-35838: Fix duplicate optionxform calls on a section's option by tirkarthi · Pull Request #11760 · python/cpython

I couldn't come across any place where the optionxform is called twice

Even if all APIs doesn't call optionxform twice, it can be called twice while using some APIs.
For example:

>>> 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'

(Note that I checked out this PR and tested above case)