Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@

from collections.abc import MutableMapping
from collections import OrderedDict as _default_dict, ChainMap as _ChainMap
from copy import deepcopy
import functools
import io
import itertools
Expand Down Expand Up @@ -964,6 +965,7 @@ def __setitem__(self, key, value):

# XXX this is not atomic if read_dict fails at any point. Then again,
# no update method in configparser is atomic in this implementation.
value = deepcopy(value)
if key == self.default_section:
self._defaults.clear()
elif key in self._sections:
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,14 @@ def test_case_sensitivity_mapping_access(self):
defaults={"key":"value"})
self.assertTrue("Key" in cf["section"])

def test_assign_itself(self):
cf = self.newconfig()
cf['test'] = {'key': 'value'}
section = cf['test']
section['key'] = 'diffrent'
cf['test'] = section
self.assertEqual(dict(section), {'key': 'diffrent'})

def test_default_case_sensitivity(self):
cf = self.newconfig({"foo": "Bar"})
self.assertEqual(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix configparser when a section is assigned to itself. Patched by Dong-
hee Na.