paul j3 added the comment:

Further observations:

parser.add_subparsers() accepts a 'dest' keyword arg, but not a 'required' one. 
 Default of 'dest' is SUPPRESS, so the name does not appear in the Namespace. 
Changing it to something like 'command' will produce an entry, e.g. 
Namespace(command=foo, ...).  Is this a problem?  

Assuming we have a clean way of assigning a name to 'subparsers', what should 
it be?  'command', '{cmd}', '{foo,bar,baz}' (like in the usage line)?  This 
name also could be used when telling the user the subparser choice is invalid 
(parser._check_value).

This issue exposes a problem with '_get_action_name()'.  This function gets a 
name from the action's option_strings, metavar or dest.  If it can't get a 
string, it returns None.

ArgumentError pays attention to whether this action name is a string or None, 
and adjusts its message accordingly.  But the new replacement for the 'too few 
arguments' error message does a ', '.join([action names]), which chokes if one 
of those names is None.  There is a mutually_exclusive_groups test that also 
uses this 'join'.  This bug should be fixed regardless of what is done with 
subparsers error messages.

So the issues are:
- making 'subparsers' a required argument
- choosing or generating an appropriate name for 'subparsers'
- passing this name to the error message (via _get_action_name?)
- correcting the handling of action names when they are unknown (None).

----------

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

Reply via email to