This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients DasIch, G2P, Julian, bethard, bewest, bkabrda, chris.jerdonek, csernazs, dsully, elsdoerfer, eric.araujo, labrat, nvie, paul.j3, r.david.murray, seblu, zzzeek
Date 2013-04-10.21:31:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1365629470.32.0.811576633203.issue9253@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2013-04-10 21:31:10paul.j3setrecipients: + paul.j3, csernazs, bethard, eric.araujo, r.david.murray, zzzeek, labrat, chris.jerdonek, nvie, DasIch, elsdoerfer, G2P, Julian, dsully, seblu, bewest, bkabrda
2013-04-10 21:31:10paul.j3setmessageid: <1365629470.32.0.811576633203.issue9253@psf.upfronthosting.co.za>
2013-04-10 21:31:10paul.j3linkissue9253 messages
2013-04-10 21:31:09paul.j3create