-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Traceback line numbers broken on Jinja 2.10.2 and newer + Python 3.7 #1104
Comments
Well, I mostly cared about the test suite not to crash :-) I was happy when the test suite passed, but I didn't check the exact traceback ;-) |
I have absolutely no idea why this is happening. |
Doing some work on this. Ditching most of def new_make_traceback(exc_info, source_hint=None):
exc_type, exc_value, tb = exc_info
tb_prev = None
while tb is not None:
t = tb.tb_frame.f_globals.get("__jinja_template__")
tb_next = tb.tb_next
if t is not None:
lineno = t.get_corresponding_lineno(tb.tb_lineno)
fake_tb = fake_exc_info(exc_info[:2] + (tb,), t.filename, lineno)[2]
tb = TracebackType(tb_next, fake_tb.tb_frame, tb.tb_lasti, lineno)
if tb_prev is not None:
tb_prev.tb_next = tb
tb_prev = tb
tb = tb_next
return exc_info Need to support Also turned out that it would have failed on 3.8 for another reason: |
Cool! Thanks for the fix. |
The 3a86ef3 commit breaks traceback line numbers on Python 3.7. (On Django, this breaks the debug traceback view altogether.)
Refs:
Thanks to @tomhamiltonstubber for the original minimal example.
Expected Behavior
Tracebacks should have correct line numbers, and source lines should be retrievable.
Actual Behavior
Tracebacks within Jinja templates have incorrect line numbers, and source is not retrievable.
Python Code
Template Code
Full Traceback
There are only 5 lines in
index.jinja
and the tracebacks point to line 10 and 19.If one cheats Jinja to use the old hack on Python 3.7, things work:
Your Environment
The text was updated successfully, but these errors were encountered: