Opened 10 years ago

Closed 10 years ago

#24663 closed Bug (duplicate)

DEBUG view AttributeError on exception value.__traceback__ in python2

Reported by: fero Owned by: fero
Component: Core (Other) Version: dev
Severity: Release blocker Keywords: debugview debug template_debug
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

While i was trying to reproduce #24539, in an "add" operation from the admin interface I get:

"A server error occurred. Please contact the administrator."

Looking at the runserver standard output I see:

Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/home/fero/src/test/django/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/home/fero/src/test/django/django/core/handlers/wsgi.py", line 177, in __call__
    response = self.get_response(request)
  File "/home/fero/src/test/django/django/core/handlers/base.py", line 217, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/home/fero/src/test/django/django/core/handlers/base.py", line 260, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/home/fero/src/test/django/django/views/debug.py", line 96, in technical_500_response
    html = reporter.get_traceback_html()
  File "/home/fero/src/test/django/django/views/debug.py", line 380, in get_traceback_html
    c = Context(self.get_traceback_data(), use_l10n=False)
  File "/home/fero/src/test/django/django/views/debug.py", line 325, in get_traceback_data
    frames = self.get_traceback_frames()
  File "/home/fero/src/test/django/django/views/debug.py", line 456, in get_traceback_frames
    tb = self.tb if not exceptions else exc_value.__traceback__
AttributeError: 'IntegrityError' object has no attribute '__traceback__'

It seems to me a very weird bug in the debug view. I am doing a sprint at pycon6 in Italy so I have shortly discussed with the sprint master and he agreed with me that this bug definitely worth to be reported.

Oh guys what a raw impact in dealing with the master!
Is it a release blocker bug? I think so
I hope I have classified it well, I have tried to setup as many ticket fields as possible.
I get this assigned to me today if you don't mind...

I keep you up-to-date

Change History (4)

comment:1 by fero, 10 years ago

I suppose that this comment is not completely true ;). Code follows

# In case there's just one exception (always in Python 2,
# sometimes in Python 3), take the traceback from self.tb (Python 2
# doesn't have a __traceback__ attribute on Exception)
exc_value = exceptions.pop()
tb = self.tb if not exceptions else exc_value.__traceback__

Just some debug printing infos...

BEFORE [
    IntegrityError('NOT NULL constraint failed: base_product.created',), 
    IntegrityError('NOT NULL constraint failed: base_product.created',)
]
AFTER exceptions.pop() [
    IntegrityError('NOT NULL constraint failed: base_product.created',)
]

comment:2 by fero, 10 years ago

Provided a "raw" patch and asked for pull request: https://github.com/django/django/pull/4530

I should know better python2 to say if this can be a definitive. I copy my pull request comment below:

this is just a raw fix I have not investigated how it can be possibile that python2 has 2 exceptions in that point of execution.

If the exceptions behaviour is wrong then the fix could do, else we have to manage multiple exceptions other than traceback attribute retrieval.

I don't know enough python now, but I have preferred to give a raw patch because of the "release critical" severity.

Furthermore I think I should provide a unittest for this case... maybe copying models from #24539 base/models.py attached files...

Version 1, edited 10 years ago by fero (previous) (next) (diff)

comment:3 by fero, 10 years ago

Has patch: set

comment:4 by Florian Apolloner, 10 years ago

Has patch: unset
Resolution: duplicate
Status: newclosed

Closing in favor of #23643 since that is where the issue was initially introduced and discussed the last weeks.

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