Opened 12 years ago

Closed 12 years ago

#18196 closed Bug (fixed)

loaddata doesn't handle ImportError exception

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

Description

Steps to reproduce:

  1. create a clean virtualenv

virtualenv virtual

  1. install django 1.4

pip install django==1.4

  1. create a project and app
  2. add wadofstuff (don't install it on the virtenv)
    SERIALIZATION_MODULES = {
        'json': 'wadofstuff.django.serializers.json'
    }
    
  3. run syncdb

Django will fail on line 123 of loaddata.py:

formats = serializers.get_public_serializer_formats()

with

*** ImportError: No module named wadofstuff.django.serializers.json

but will trough this error:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 164, in handle_noargs
    call_command('loaddata', 'initial_data', verbosity=verbosity, database=db)
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command
    return klass.execute(*args, **defaults)
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 239, in handle
    (full_path, ''.join(traceback.format_exception(sys.exc_type,
UnboundLocalError: local variable 'full_path' referenced before assignment

Issue is on the exception handler line 230.

Attachments (2)

18196-1.diff (3.7 KB ) - added by Claude Paroz 12 years ago.
More precise exception catching
18196-2.diff (3.9 KB ) - added by Claude Paroz 12 years ago.
Updated to current trunk

Download all attachments as: .zip

Change History (6)

comment:1 by Jannis Leidel, 12 years ago

Triage Stage: UnreviewedAccepted

by Claude Paroz, 12 years ago

Attachment: 18196-1.diff added

More precise exception catching

comment:2 by Claude Paroz, 12 years ago

Has patch: set

comment:3 by Claude Paroz, 12 years ago

#17853 has been marked as a dup of this one.

by Claude Paroz, 12 years ago

Attachment: 18196-2.diff added

Updated to current trunk

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

Resolution: fixed
Status: newclosed

In [4353a6163c00d4193307dae533e3e6ae9b44d18f]:

Fixed #18196 -- Improved loaddata error messages.

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