﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6420	Option show_traceback in loaddata.py causes problems with transactions on exceptions	Grzegorz Lukasik <hauserx@…>	nobody	"Option show_traceback in loaddata does not work properly - instead of correct traceback TransactionManagementError is displayed.

Option show_traceback was introduced in this commit:

http://code.djangoproject.com/changeset/6936


Relevant parts of code that cause this problem:

{{{
 78                     try:
...
 93                             try:
...
100                             except Exception, e:
101                                 fixture.close()
102                                 transaction.rollback()
103                                 transaction.leave_transaction_management()
104                                 if show_traceback:
105                                     raise
106                                 sys.stderr.write(
107                                     self.style.ERROR(""Problem installing fixture '%s': %s\n"" %
108                                          (full_path, str(e))))
109                                 return
110                             fixture.close()
111                     except:
112                         if verbosity > 2:
113                             print ""No %s fixture '%s' in %s."" % \
114                                 (format, fixture_name, humanize(fixture_dir))
...
124         transaction.commit()
125         transaction.leave_transaction_management()
}}}

In case of error in line 103 transaction block is finished and exception is raised again, but in line 111 this exception is cached and processing continues. If option show_traceback is turned off, it simply returns from the command in line 109 so it is ok then.

Example:

{{{
$ python manage.py loaddata backup.json --traceback
Installing json fixture 'backup' from absolute path.
Traceback (most recent call last):
  File ""manage.py"", line 21, in <module>
    execute_manager(settings)
  File ""/usr/lib/python2.5/site-packages/django/core/management/__init__.py"", line 272, in execute_manager
    utility.execute()
  File ""/usr/lib/python2.5/site-packages/django/core/management/__init__.py"", line 219, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/usr/lib/python2.5/site-packages/django/core/management/base.py"", line 72, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/usr/lib/python2.5/site-packages/django/core/management/base.py"", line 86, in execute
    output = self.handle(*args, **options)
  File ""/usr/lib/python2.5/site-packages/django/core/management/commands/loaddata.py"", line 125, in handle
    transaction.leave_transaction_management()
  File ""/usr/lib/python2.5/site-packages/django/db/transaction.py"", line 67, in leave_transaction_management
    raise TransactionManagementError(""This code isn't under transaction management"")
django.db.transaction.TransactionManagementError: This code isn't under transaction management
}}}"		closed	Core (Other)	dev		fixed			Unreviewed	1	0	0	0	0	0
