[ python-Bugs-1090076 ] Defaults in ConfigParser.get overrides
section values
SourceForge.net
noreply at sourceforge.net
Wed Dec 22 23:23:32 CET 2004
Bugs item #1090076, was opened at 2004-12-22 19:23
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1090076&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Gabriel Genellina (gagenellina)
Assigned to: Nobody/Anonymous (nobody)
Summary: Defaults in ConfigParser.get overrides section values
Initial Comment:
ConfigParser.get has an optional argument vars that -
according to the docstring- "which must be a dictionary
whose contents overrides any pre-existing defaults."
I understand that it overrides the default values, but
should not override an actual value existing in the file.
That is, given this contents:
[DEFAULT]
key1=default1
[section]
key2=value2
vars={'key1:vars1','key2:vars2'}
cfg.get('section','key1',0,vars) gives 'vars1' (ok)
cfg.get('section','key2',0,vars) gives 'vars2' (wrong,
should be 'value2', since key2 is actually in the section
and no default is needed).
To correct this behavior, simply move this two lines of
code up in ConfigParser.get (ConfigParser.py), just below
the first line and before the first try/except:
# Update with the entry specific variables
if vars is not None:
d.update(vars)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1090076&group_id=5470
More information about the Python-bugs-list
mailing list