[Django] #22066: KeyError in settings.py leads to baffling 'Unknown command' error

2 views
Skip to first unread message

Django

unread,
Feb 16, 2014, 11:52:38 AM2/16/14
to django-...@googlegroups.com
#22066: KeyError in settings.py leads to baffling 'Unknown command' error
--------------------------------------------+--------------------
Reporter: michael.karl.coleman@… | Owner: nobody
Type: Bug | Status: new
Component: Core (Management commands) | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------------+--------------------
In two places in core/management/__init__.py, there is code like this
{{{
try:
app_name = get_commands()[name]
except KeyError:
raise CommandError("Unknown command: %r" % name)
}}}
Unfortunately, KeyErrors from settings.py seem to get caught here, leading
to a baffling error message. The fix would be to just do something like
{{{
commands = get_commands()
if name not in commands:
raise CommandError("Unknown command: %r" % name)
app_name = name
}}}
and let any KeyError from settings.py escape as a backtrace, so that the
user can see and fix it directly.

Unfortunately, I don't have time to recreate this and verify that it still
exists in HEAD, but just looking at the code, I think it probably does.

This is related to #19257, but I don't believe it's the same bug.

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

Django

unread,
Feb 16, 2014, 2:53:03 PM2/16/14
to django-...@googlegroups.com
#22066: KeyError in settings.py leads to baffling 'Unknown command' error
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
michael.karl.coleman@… | Status: closed
Type: Bug | Version: 1.6
Component: Core (Management | Resolution: duplicate
commands) | Triage Stage:
Severity: Normal | Unreviewed
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by claudep):

* status: new => closed
* needs_docs: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

I do think that the fix for #19257 addresses your concern. Reopen if you
can reproduce with master (1.7).

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

Reply all
Reply to author
Forward
0 new messages