summaryrefslogtreecommitdiff
path: root/jinja2/debug.py
diff options
context:
space:
mode:
Diffstat (limited to 'jinja2/debug.py')
-rw-r--r--jinja2/debug.py16
1 files changed, 11 insertions, 5 deletions
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