diff options
author | David Lord <davidism@gmail.com> | 2019-09-04 07:48:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-04 07:48:06 -0700 |
commit | 72fffe41a2280ebab01745804c517a33f4a6cf08 (patch) | |
tree | 3220d2221e5d92a544f1ae5295f7aad2890e0efa | |
parent | d601b3f49625356616e2f88ef82e3fe5673ea873 (diff) | |
parent | 3a86ef3d72fdefb149c0c859e6e37035826f3557 (diff) | |
download | jinja2-72fffe41a2280ebab01745804c517a33f4a6cf08.tar.gz |
Merge pull request #1051 from vstinner/tb_next_py37
Fix TracebackFrameProxy.set_next() on Python 3.7
-rw-r--r-- | CHANGES.rst | 2 | ||||
-rw-r--r-- | jinja2/debug.py | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 3199d55..9bf0481 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 diff --git a/jinja2/debug.py b/jinja2/debug.py index b61139f..d3c1a3a 100644 --- a/jinja2/debug.py +++ b/jinja2/debug.py @@ -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 |