You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2019-02-17.01:34:39.553>created_at=<Date2017-11-21.17:46:10.957>labels= ['3.7', '3.8', 'type-bug', 'library']
title='configparser bug: section is emptied if you assign a section to itself'updated_at=<Date2019-02-17.01:34:39.553>user='https://bugs.python.org/simonltwick'
If you assign a ConfigParser section back to the parent ConfigParser object (say after updating the section), the section is emptied.
(I realise now that you don't need to assign the section back to the parent as it's a proxy for the section in the parent already - but still it does not behave as you would expect):
code:
from configparser import ConfigParser
config = ConfigParser()
config['test'] = {'key': 'value'}
section = config['test']
section['key'] = 'different'
print("before: config['test'] is %s" % dict(config['test']))
config['test'] = section
print("after: config['test'] is %s" % dict(config['test']))
# the section is now printed as {}
PR 4607 doesn't look a correct solution to me. I don't know a precedence of calling deepcopy() for a value in __setitem__(). deepcopy() is too heavy, calling it can slow down normal cases. Using deepcopy likely means a bad design.
New changeset 33cd058 by Łukasz Langa (Cheryl Sabella) in branch 'master': bpo-32108: Don't clear configparser values if key is assigned to itself (GH-7588) 33cd058
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: