paul j3 added the comment:

A possible problem with this patch is that it overrides any Namespace given by 
the user.  In the test example:

    parser.parse_args(['X'], namespace=argparse.Namespace(foo=3))

the result is 'foo=2', the setdefault from the subparser.  Previously, and with 
a single level parser, the result would be 'foo=3'.  This is also true for an 
ordinary argument default in the subparser.

It could be argued that a user is unlikely to use both the 'namespace=...' 
parameter, and 'setdefault' for the same variable, especially one that isn't an 
argument 'dest'.  But the fact that the  custom namespace does not override 
regular subparser argument defaults bothers me.

Also, should an untested change like this be applied to 3.4 and 2.7?  This is 
not a backward compatible bug fix.

The test case also touches on a real bug in the recent releases - subparsers 
are now optional.  'parser.parse_args([])' runs without complaint about the 
missing 'X'.  Actually it is convenient for testing this case.  But it is still 
an incompatibility with earlier behavior

http://bugs.python.org/issue9253

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9351>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to