Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #27799 -- Only add 'args' argument once to command parser. #8002

Closed
wants to merge 1 commit into from

Conversation

dracos
Copy link
Contributor

@dracos dracos commented Jan 31, 2017

If a custom management LabelCommand or AppCommand uses 'args' then only
the last positional argument provided is passed to the command, because
argparse's behaviour when two calls to add_argument with the same name
is undefined (it appears to put all the arguments bar one in the first
'*' argument, then the last one in the '+' argument).

This shows this with a test, and fixes it by not making the first call
to parser.add_argument('args') if it's a LabelCommand or AppCommand.

If a custom management LabelCommand or AppCommand uses 'args' then only
the last positional argument provided is passed to the command, because
argparse's behaviour when two calls to add_argument with the same name
is undefined (it appears to put all the arguments bar one in the first
'*' argument, then the last one in the '+' argument).

This shows this with a test, and fixes it by not making the first call
to parser.add_argument('args') if it's a LabelCommand or AppCommand.
@timgraham timgraham changed the title Only add 'args' argument once to command parser. Fixed #27799 -- Only add 'args' argument once to command parser. Jan 31, 2017
@timgraham
Copy link
Member

Closing per ticket.

@timgraham timgraham closed this Jan 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants