From 1efb4cc918b4f3d097c376596da101de9f76585a Mon Sep 17 00:00:00 2001 From: Thomas Moschny Date: Tue, 19 Jan 2021 17:46:19 +0100 Subject: [PATCH 1/2] Add 'linetable' to the list of preserved CodeType attributes. As part of https://github.com/python/cpython/pull/23113 partly implementing PEP 626 (see https://bugs.python.org/issue42246), the co_lnotab member of struct PyCodeObject was replaced by co_linetable, implementing a new line number table. This commit therefore adds linetable to the list of attributes that are copied over into the final CodeType executed by fake_traceback() to ensure proper line numbers and contents in fake stack traces generated when running under Python 3.10. Fixes #1333. --- src/jinja2/debug.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jinja2/debug.py b/src/jinja2/debug.py index 5cac28baa..c2375e896 100644 --- a/src/jinja2/debug.py +++ b/src/jinja2/debug.py @@ -130,6 +130,7 @@ def fake_traceback(exc_value, tb, filename, lineno): "lnotab", "freevars", "cellvars", + "linetable", # Python 3.10 ): if isinstance(attr, tuple): # Replace with given value. From 792a94c18a3c638d80528e08db8d2fd30969beba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Jan 2021 17:10:21 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/jinja2/debug.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jinja2/debug.py b/src/jinja2/debug.py index c2375e896..fac571998 100644 --- a/src/jinja2/debug.py +++ b/src/jinja2/debug.py @@ -130,7 +130,7 @@ def fake_traceback(exc_value, tb, filename, lineno): "lnotab", "freevars", "cellvars", - "linetable", # Python 3.10 + "linetable", # Python 3.10 ): if isinstance(attr, tuple): # Replace with given value.