Opened 4 years ago

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


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)
        'json': 'wadofstuff.django.serializers.json'
  3. run syncdb

Django will fail on line 123 of

formats = serializers.get_public_serializer_formats()


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

but will trough this error:

Traceback (most recent call last):
  File "", line 10, in <module>
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/", line 443, in execute_from_command_line
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/", line 382, in execute
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/", 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/", line 232, in execute
    output = self.handle(*args, **options)
  File "/home/nxvl/dev/repuesport/virtual/local/lib/python2.7/site-packages/django/core/management/", 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/", 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/", 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/", 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/", 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 claudep 4 years ago.
More precise exception catching
18196-2.diff (3.9 KB) - added by claudep 4 years ago.
Updated to current trunk

Download all attachments as: .zip

Change History (6)

comment:1 Changed 4 years ago by jezdez

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 4 years ago by claudep

More precise exception catching

comment:2 Changed 4 years ago by claudep

  • Has patch set

comment:3 Changed 4 years ago by claudep

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

Changed 4 years ago by claudep

Updated to current trunk

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

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

In [4353a6163c00d4193307dae533e3e6ae9b44d18f]:

Fixed #18196 -- Improved loaddata error messages.

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