Opened 7 years ago

Closed 7 years ago

#28485 closed Bug (fixed)

Make ExceptionReporter.get_traceback_frames() include frames without source code

Reported by: Martin von Gagern Owned by: Tim Graham <timograham@…>
Component: Error reporting Version: dev
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

Recently I encountered a strange situation: I got an exception for a bad method signature, but the stack trace shown by Django in the error response did not even mention the method in question. I added a traceback.print_exc() to the last report function, and there on standard error I could see some more frames. They were without source code, but with file name, line number and method name. The reason why they were without source code was that their source was not directly accessible as a file on disk. They had been loaded via a custom loading procedure. The fact that there was no indication at all in the report was quite confusing.

In GitHub #8880 I'm proposing a fix for this. If we fail to load the source file, we no longer drop the frame but present what information we have, namely file name, line number and function name, plus a warning about the unavability of the source file in place of the actual source test.

Note that having a PEP 302 __loader__ to the generated module to provide a get_source method is a way of supporting source code even for generated or custom-loaded code, and it is supported by Django. So this change here does not affect all generated or custom-loaded code, only those parts which don't make use of such a loader.

Attachments (1)

f51ded156e1b8ef8b59bc10b01100de6c3021ab3.patch (4.6 KB ) - added by Martin von Gagern 7 years ago.
GitHub8880.patch

Download all attachments as: .zip

Change History (4)

by Martin von Gagern, 7 years ago

GitHub8880.patch

comment:1 by Srinivas Reddy Thatiparthy, 7 years ago

comment:2 by Tim Graham, 7 years ago

Summary: Stack trace report silently drops frames without source codeMake ExceptionReporter.get_traceback_frames() include frames without source code
Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham <timograham@…>, 7 years ago

Owner: set to Tim Graham <timograham@…>
Resolution: fixed
Status: newclosed

In 71d39571:

Fixed #28485 -- Made ExceptionReporter.get_traceback_frames() include frames without source code.

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