[Django] #27799: If 'args' is used on a custom LabelCommand or AppCommand subclass, only the last positional arg is supplied to the command

6 views
Skip to first unread message

Django

unread,
Jan 31, 2017, 9:50:16 AM1/31/17
to django-...@googlegroups.com
#27799: If 'args' is used on a custom LabelCommand or AppCommand subclass, only the
last positional arg is supplied to the command
----------------------------------------------+------------------------
Reporter: Matthew Somerville | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------------+------------------------
argparse has undefined behaviour if add_argument is called twice with the
same name – Django does this for LabelCommand and AppCommand when
self.args is used, the first call to parser.add_argument('args') in
BaseCommand, the second in LabelCommand/AppCommand.

What appears to happen is you get only the last positional argument
supplied to your command; if the '*' and the '+' had been the other way
round, you would get nothing.

--
Ticket URL: <https://code.djangoproject.com/ticket/27799>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 31, 2017, 9:50:59 AM1/31/17
to django-...@googlegroups.com
#27799: If 'args' is used on a custom LabelCommand or AppCommand subclass, only the
last positional arg is supplied to the command
------------------------------------+--------------------------------------

Reporter: Matthew Somerville | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------

Comment (by Matthew Somerville):

Pull request at https://github.com/django/django/pull/8002

--
Ticket URL: <https://code.djangoproject.com/ticket/27799#comment:1>

Django

unread,
Jan 31, 2017, 10:09:23 AM1/31/17
to django-...@googlegroups.com
#27799: If 'args' is used on a custom LabelCommand or AppCommand subclass, only the
last positional arg is supplied to the command
-------------------------------------+-------------------------------------

Reporter: Matthew Somerville | Owner: nobody
Type: Bug | Status: closed
Component: Core (Management | Version: 1.8
commands) |
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => wontfix
* component: Uncategorized => Core (Management commands)


Comment:

As discussed in #django-dev, the correct solution for your use case seems
to be to use the `LabelCommand.label` attribute rather than `args`. This
is fixed in 1.10 with the removal of the `args` attribute.

Nearly 2 years after the release of 1.8 and with 1 year of support left, I
don't think it's critical to change in 1.8 at this point.

--
Ticket URL: <https://code.djangoproject.com/ticket/27799#comment:2>

Reply all
Reply to author
Forward
0 new messages