Fixes `__setitem__` on parser['DEFAULT'] reported in issue #16820.
diff --git a/Lib/configparser.py b/Lib/configparser.py
index be1c9f3..eac508e 100644
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -960,7 +960,10 @@
# 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 == self.default_section:
+ self._defaults.clear()
+ else:
+ self.remove_section(key)
self.read_dict({key: value})
def __delitem__(self, key):