Bugs item #1090076, was opened at 2004-12-22 23:23 Message generated for change (Comment added) made by loewis 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: Martin v. Löwis (loewis) Date: 2005-03-03 11:21 Message: Logged In: YES user_id=21627 I believe the current behaviour is there ever since revision 1.6, when the vars parameter was first introduced. The commit message says date: 1999/01/26 19:29:25; author: guido; state: Exp; lines: +17 -6 Patch by Chris Petrilli (not really tested since I don't know this module myself) to accept an option keyword argument (vars) that is substituted on top of the defaults that were setup in __init__. The patch also fixes the problem where you can't have recusive references inside your configuration file. We might want to ask Petrilli what the intention of this feature was, or just proceed with changing the documentation (and docstrings); contributions in that direction are welcome. I agree with anadelonbrin that the proposed change is probably not adequate. ---------------------------------------------------------------------- Comment By: Tony Meyer (anadelonbrin) Date: 2005-01-31 01: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 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com