]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Fix TracebackFrameProxy.set_next() on Python 3.7 1051/head
authorVictor Stinner <vstinner@redhat.com>
Mon, 19 Aug 2019 22:40:39 +0000 (00:40 +0200)
committerDavid Lord <davidism@gmail.com>
Wed, 4 Sep 2019 14:40:52 +0000 (07:40 -0700)
Fix issue #1050: fix a crash in TracebackFrameProxy.set_next() on
Python 3.7 and newer, when Python is build in debug mode.

Since Python 3.7, traceback.tb_next field can be modified: ctypes is
no longer needed.

CHANGES.rst
jinja2/debug.py

index 3199d559ef86605a8826410d93d118c8668ec0da..9bf04814311fdee173f850ca734b8639eb638a4d 100644 (file)
@@ -8,6 +8,8 @@ Unreleased
 -   Fix Python 3.7 deprecation warnings.
 -   Using ``range`` in the sandboxed environment uses ``xrange`` on
     Python 2 to avoid memory use. :issue:`933`
+-   Use Python 3.7's better traceback support to avoid a core dump when
+    using debug builds of Python 3.7. :issue:`1050`
 
 
 Version 2.10.1
index b61139f0cde17f4914b66bdd541ff149f492fe1d..d3c1a3a87551d90ec87980657786d81b50013ba5 100644 (file)
@@ -365,8 +365,14 @@ def _init_ugly_crap():
 # proxies.
 tb_set_next = None
 if tproxy is None:
-    try:
-        tb_set_next = _init_ugly_crap()
-    except:
-        pass
-    del _init_ugly_crap
+    # traceback.tb_next can be modified since CPython 3.7
+    if sys.version_info >= (3, 7):
+        def tb_set_next(tb, next):
+            tb.tb_next = next
+    else:
+        # On Python 3.6 and older, use ctypes
+        try:
+            tb_set_next = _init_ugly_crap()
+        except Exception:
+            pass
+del _init_ugly_crap