summaryrefslogtreecommitdiffstats
path: root/Lib/configparser.py
diff options
context:
space:
mode:
authorŁukasz Langa <lukasz@langa.pl>2013-01-01 22:45:33 (GMT)
committerŁukasz Langa <lukasz@langa.pl>2013-01-01 22:45:33 (GMT)
commita2e7acd17d64cfef3f502473c3b56db8cce24234 (patch)
tree702d51c468cf9ea9d9e3a17ad02948334aaf8574 /Lib/configparser.py
parente4110dc11f9e90d3a7fcd8f0a5f9ded344f433c6 (diff)
downloadcpython-a2e7acd17d64cfef3f502473c3b56db8cce24234.zip
cpython-a2e7acd17d64cfef3f502473c3b56db8cce24234.tar.gz
cpython-a2e7acd17d64cfef3f502473c3b56db8cce24234.tar.bz2
configparser: preserve section order when using `__setitem__` (issue #16820)
Diffstat (limited to 'Lib/configparser.py')
-rw-r--r--Lib/configparser.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/configparser.py b/Lib/configparser.py
index 243efec..e5536a0 100644
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -959,7 +959,8 @@ class RawConfigParser(MutableMapping):
# XXX this is not atomic if read_dict fails at any point. Then again,
# no update method in configparser is atomic in this implementation.
- self.remove_section(key)
+ if key in self._sections:
+ self._sections[key].clear()
self.read_dict({key: value})
def __delitem__(self, key):