Skip to content

Commit

Permalink
[1.5.x] Fixed #19257 -- Don't swallow command's KeyError in call_command
Browse files Browse the repository at this point in the history
Thanks Giovanni Bajo for the report.
Backport of 9a09558 from master.
  • Loading branch information
claudep committed Nov 7, 2012
1 parent 5b19073 commit 34d0c30
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions django/core/management/__init__.py
Expand Up @@ -136,14 +136,15 @@ def call_command(name, *args, **options):
# Load the command object. # Load the command object.
try: try:
app_name = get_commands()[name] app_name = get_commands()[name]
if isinstance(app_name, BaseCommand):
# If the command is already loaded, use it directly.
klass = app_name
else:
klass = load_command_class(app_name, name)
except KeyError: except KeyError:
raise CommandError("Unknown command: %r" % name) raise CommandError("Unknown command: %r" % name)


if isinstance(app_name, BaseCommand):
# If the command is already loaded, use it directly.
klass = app_name
else:
klass = load_command_class(app_name, name)

# Grab out a list of defaults from the options. optparse does this for us # Grab out a list of defaults from the options. optparse does this for us
# when the script runs from the command line, but since call_command can # when the script runs from the command line, but since call_command can
# be called programatically, we need to simulate the loading and handling # be called programatically, we need to simulate the loading and handling
Expand Down

0 comments on commit 34d0c30

Please sign in to comment.