bpo-32108: Don't clear configparser values if key is assigned to itself by csabella · Pull Request #7588 · python/cpython (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will slow down the general case because !=
checks whether all keys and values in a mapping are the same.
The problem outlined in BPO-32108 only happens if value
is a SectionProxy. Only in this case clearing the underlying dictionary will cause the subsequent read_dict()
to fail.
So, instead of those checks, on line 967 make the following check:
if key in self and self[key] is value:
return
self[key]
returns a SectionProxy for the given section. If the value
is that same proxy, we don't need to do anything.