Opened 7 years ago

Closed 7 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


The code in 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

Change History (3)

comment:1 Changed 7 years ago by giovannibajo

Cc: giovannibajo added

comment:2 Changed 7 years ago by Claude Paroz

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 Changed 7 years ago by Claude Paroz <claude@…>

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