Opened 12 years ago

Closed 12 years ago

#19257 closed Bug (fixed)

KeyError swallowed while loading command classes

Reported by: giovannibajo Owned by: nobody
Component: Core (Management commands) Version: 1.4
Severity: Normal Keywords:
Cc: giovannibajo Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The code in django.core.management.call_command() swallows all KeyErrors generated while loading a command class, and turns them into a "command unknown" error message.

The Test command for instance executes user's code while loading the command class (see django.test.simple, line 36), so any kind of KeyError in user code while running tests gets swallowed and turned into a "unknown command test", which baffles the user.

I don't know whether it's a bug in call_command() (should check for KeyErrors only while looking up a command in the command dictionaries) or in the test framework (shouldn't let user exceptions slip out of simple.py).

Change History (3)

comment:1 by giovannibajo, 12 years ago

Cc: giovannibajo added

comment:2 by Claude Paroz, 12 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

I think you are right and that the except KeyError clause should only catch for get_commands()[name].

comment:3 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 9a09558e9f20e088b4526fff6374a53e877cf5ec:

Fixed #19257 -- Don't swallow command's KeyError in call_command

Thanks Giovanni Bajo for the report.

Note: See TracTickets for help on using tickets.
Back to Top