{{{
#!python
class TestView(View):
def get(self, request, *args, **kwargs):
try:
raise RuntimeError('my error')
except Exception as exc:
# Uncommenting these two lines causes the debug
# server error view not to show **any** portion
# of the traceback.
# new_exc = RuntimeError('my context')
# exc.__context__ = new_exc
raise
}}}
If the indicated lines are uncommented, then the debug error view shows no
traceback info at all.
This is because `django.views.debug.get_traceback_frames()` starts at the
innermost exception in the chain, and then stops adding frames when it
encounters the first exception with `None`-valued
`exc_value.__traceback__`:
https://github.com/django/django/blob/38a21f2d9ed4f556af934498ec6a242f6a20418a/django/views/debug.py#L391
{{{
#!python
exc_value = exceptions.pop()
tb = self.tb if not exceptions else exc_value.__traceback__
while tb is not None:
# Get frame.
...
frames.append({
...
})
# If the traceback for current exception is consumed, try the
# other exception.
if not tb.tb_next and exceptions:
exc_value = exceptions.pop()
tb = exc_value.__traceback__
else:
tb = tb.tb_next
return frames
}}}
It would probably be better and simpler if instead the while loop were
structured to iterate over every exception in the chain no matter what,
and include traceback info only for those exceptions with non-`None`
`__traceback__`. In other words, something like the following:
{{{
#!python
while exceptions:
exc_value = exceptions.pop()
# Returns placeholder frame with no `tb` info if
# `exc_value.__traceback__ is None`.
exc_frames = self.get_traceback_frames(exc_value)
frames.extend(exc_frames)
}}}
This way, the debug error view would always show the complete exception
chain, even if some exceptions in the chain have a `None`-valued traceback
attribute.
--
Ticket URL: <https://code.djangoproject.com/ticket/31672>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Chris Jerdonek):
Here is a related (but different) issue about the traceback shown by the
debug error view ("debug error view doesn't respect
exc.__suppress_context__ (PEP 415)"):
https://code.djangoproject.com/ticket/31674
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:1>
Comment (by Chris Jerdonek):
Sure, I'll see if I can find time to put something together for this and
the others.
By the way, have there been any issues with people not receiving all email
notifications from `code.djangoproject.com`? It seems like I don't get
some of them (not even to my spam folder).
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:3>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:5>
Comment (by felixxm):
Fixed by 78ae8cc5d8aff65afbf35947421a8a1aba13bfab.
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:8>
* status: assigned => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:9>
Comment (by Chris Jerdonek):
Thanks for fixing the issue!
I looked at the PR after this was merged and made a comment:
https://github.com/django/django/pull/13513#issuecomment-707355649
By the way, I didn't get another email about this ticket until after the
PR was merged and approved. I think it might be a good addition to your
process in general if you could CC the reporter on any PR or otherwise
notify them (maybe this could be done automatically) to ensure they also
have a chance to see it before it's merged. I know this isn't the first
time I didn't have a chance to see a fix for an issue I reported until
after it was merged. In many cases, the extra pair of eyes can help
because the original reporter may have insights the PR author doesn't have
since they spent the time finding and diagnosing it.
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:10>
Comment (by felixxm):
Chris, thanks for comments. Reporters should get notifications about all
updates. I'm not sure why you didn't get them. 🤔
> In many cases, the extra pair of eyes can help because the original
reporter may have insights the PR author doesn't have since they spent the
time finding and diagnosing it.
Totally agreed, I will ping you directly in PRs in the future, thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:11>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"a492ccf0bc3da0b99c27b44e491ec3d6aabd5d3f" a492ccf0]:
{{{
#!CommitTicketReference repository=""
revision="a492ccf0bc3da0b99c27b44e491ec3d6aabd5d3f"
Refs #31672 -- Simplified ExceptionReporter.get_traceback_frames().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:15>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/13637 PR] to address
[https://code.djangoproject.com/ticket/31672#comment:13 Mariusz comment].
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:16>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:17>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:18>
* status: new => assigned
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:19>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:20>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:21>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"4cd77f97a2d30d58841041a73d277ec4bfb7b530" 4cd77f97]:
{{{
#!CommitTicketReference repository=""
revision="4cd77f97a2d30d58841041a73d277ec4bfb7b530"
Refs #31672 -- Made technical 500 debug page include exceptions without
tracebacks.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:22>
* status: assigned => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/31672#comment:23>