Index: third_party/jinja2/debug.py |
diff --git a/third_party/jinja2/debug.py b/third_party/jinja2/debug.py |
index 815cc18a4f8fd76e747835f24c1297a7d2264628..3252748369484f75025fd90ae4f3dcb4e1232900 100644 |
--- a/third_party/jinja2/debug.py |
+++ b/third_party/jinja2/debug.py |
@@ -12,10 +12,10 @@ |
""" |
import sys |
import traceback |
-from types import TracebackType |
+from types import TracebackType, CodeType |
from jinja2.utils import missing, internal_code |
from jinja2.exceptions import TemplateSyntaxError |
-from jinja2._compat import iteritems, reraise, code_type |
+from jinja2._compat import iteritems, reraise, PY2 |
# on pypy we can take advantage of transparent proxies |
try: |
@@ -245,12 +245,21 @@ def fake_exc_info(exc_info, filename, lineno): |
location = 'block "%s"' % function[6:] |
else: |
location = 'template' |
- code = code_type(0, code.co_nlocals, code.co_stacksize, |
- code.co_flags, code.co_code, code.co_consts, |
- code.co_names, code.co_varnames, filename, |
- location, code.co_firstlineno, |
- code.co_lnotab, (), ()) |
- except: |
+ |
+ if PY2: |
+ code = CodeType(0, code.co_nlocals, code.co_stacksize, |
+ code.co_flags, code.co_code, code.co_consts, |
+ code.co_names, code.co_varnames, filename, |
+ location, code.co_firstlineno, |
+ code.co_lnotab, (), ()) |
+ else: |
+ code = CodeType(0, code.co_kwonlyargcount, |
+ code.co_nlocals, code.co_stacksize, |
+ code.co_flags, code.co_code, code.co_consts, |
+ code.co_names, code.co_varnames, filename, |
+ location, code.co_firstlineno, |
+ code.co_lnotab, (), ()) |
+ except Exception as e: |
pass |
# execute the code and catch the new traceback |
@@ -273,11 +282,15 @@ def _init_ugly_crap(): |
import ctypes |
from types import TracebackType |
- # figure out side of _Py_ssize_t |
- if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'): |
- _Py_ssize_t = ctypes.c_int64 |
+ if PY2: |
+ # figure out size of _Py_ssize_t for Python 2: |
+ if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'): |
+ _Py_ssize_t = ctypes.c_int64 |
+ else: |
+ _Py_ssize_t = ctypes.c_int |
else: |
- _Py_ssize_t = ctypes.c_int |
+ # platform ssize_t on Python 3 |
+ _Py_ssize_t = ctypes.c_ssize_t |
# regular python |
class _PyObject(ctypes.Structure): |