[New-bugs-announce] [issue32108] configparser bug: section is emptied if you assign a section to itself

Simon Lambourn report at bugs.python.org
Tue Nov 21 12:46:10 EST 2017


New submission from Simon Lambourn <simon.lambourn at gmail.com>:

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 {}

----------
components: Library (Lib)
messages: 306675
nosy: simonltwick
priority: normal
severity: normal
status: open
title: configparser bug: section is emptied if you assign a section to itself
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32108>
_______________________________________


More information about the New-bugs-announce mailing list