Skip to content

rewrite traceback rewriting support#1110

Merged
davidism merged 1 commit intomasterfrom
patch-traceback
Dec 2, 2019
Merged

rewrite traceback rewriting support#1110
davidism merged 1 commit intomasterfrom
patch-traceback

Conversation

@davidism
Copy link
Copy Markdown
Member

@davidism davidism commented Dec 2, 2019

This greatly simplifies the jinja.debug code.

On Python >= 3.7, tb_next is directly assignable. On PyPy, use transparent proxies only if support is enabled. For cpython < 3.7, use ctypes to set tb_next. Rewrite the ctypes code to use py_object and pythonapi.Py_IncRef, which seems to avoid crashing on debug builds. Fixes #1104

On Python 3, a rewritten TemplateSyntaxError would retain the frames from the compiler functions for some reason. Clear these so the template source is the last thing in the traceback. Fixes #763

Simplify the `jinja.debug` code.

On Python >= 3.7, `tb_next` is directly assignable. On PyPy, use
transparent proxies only if support is enabled. For cpython < 3.7, use
ctypes to set `tb_next`. Rewrite the ctypes code to use `py_object` and
`pythonapi.Py_IncRef`, which seems to avoid crashing on debug builds.

On Python 3, a rewritten `TemplateSyntaxError` would retain the frames
from the compiler functions for some reason. Clear these so the template
source is the last thing in the traceback.
@davidism davidism added this to the 2.11.0 milestone Dec 2, 2019
@davidism davidism merged commit 41df8a5 into master Dec 2, 2019
@davidism davidism deleted the patch-traceback branch December 2, 2019 21:08
@davidism
Copy link
Copy Markdown
Member Author

davidism commented Dec 3, 2019

It seems that PyPy 2 and 3 don't clear the exception's original traceback, so TemplateSyntaxError still shows up in the middle of a bunch of compiler frames for those.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Traceback line numbers broken on Jinja 2.10.2 and newer + Python 3.7 actual error seems hidden in traceback during TemplateSyntaxError

1 participant