Code

#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).

Attachments (0)

Change History (3)

comment:1 Changed 18 months ago by giovannibajo

  • Cc giovannibajo added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 18 months ago by claudep

  • Easy pickings set
  • Triage Stage changed from Unreviewed to Accepted

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

comment:3 Changed 18 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 9a09558e9f20e088b4526fff6374a53e877cf5ec:

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

Thanks Giovanni Bajo for the report.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.