[ python-Bugs-1090076 ] Defaults in ConfigParser.get overrides
section values
SourceForge.net
noreply at sourceforge.net
Mon Jan 31 01:42:21 CET 2005
Bugs item #1090076, was opened at 2004-12-23 11:23
Message generated for change (Comment added) made by anadelonbrin
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)
----------------------------------------------------------------------
Comment By: Tony Meyer (anadelonbrin)
Date: 2005-01-31 13:42
Message:
Logged In: YES
user_id=552329
This is indeed what happens. However, changing this could
break existing code, so an alternative fix would be to
change the documentation to "overrides any pre-existing
values.". I am not sure what the desired behaviour is - if
it is what is current, then recommend updating the
documentation. If the desired behaviour is what the
documentation currently says, then recommend applying the
above patch (although the code is not exactly the same
anymore, the effect is).
----------------------------------------------------------------------
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