Skip to content
Myr

fix the fancy tracebacks on Python 3

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Antti Haapala · committed by Antti Haapala · parent bd93bf3 · Browse files · 1 file+24 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−11 removed

  • other:+24 added−11 removed

1 file+24 added−11 removed

modified:jinja2/debug.py+24 added-11 removed
13 unmodified lines
14import traceback15from types import TracebackType, CodeType16from jinja2.utils import missing, internal_code17from jinja2.exceptions import TemplateSyntaxError18from jinja2._compat import iteritems, reraise18from jinja2._compat import iteritems, reraise, PY21920# on pypy we can take advantage of transparent proxies21try:22 from __pypy__ import tproxy
221 unmodified lines
244 elif function.startswith('block_'):245 location = 'block "%s"' % function[6:]246 else:247 location = 'template'248249 if PY2:248 code = CodeType(0, code.co_nlocals, code.co_stacksize,249 code.co_flags, code.co_code, code.co_consts,250 code.co_names, code.co_varnames, filename,251 location, code.co_firstlineno,252 code.co_lnotab, (), ())253 except:250 code = CodeType(0, code.co_nlocals, code.co_stacksize,251 code.co_flags, code.co_code, code.co_consts,252 code.co_names, code.co_varnames, filename,253 location, code.co_firstlineno,254 code.co_lnotab, (), ())255 else:256 code = CodeType(0, code.co_kwonlyargcount,257 code.co_nlocals, code.co_stacksize,258 code.co_flags, code.co_code, code.co_consts,259 code.co_names, code.co_varnames, filename,260 location, code.co_firstlineno,261 code.co_lnotab, (), ())262 except Exception as e:263 pass264265 # execute the code and catch the new traceback266 try:
14 unmodified lines
281 """282 import ctypes283 from types import TracebackType284285 if PY2:276 # figure out size of _Py_ssize_t277 if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):278 _Py_ssize_t = ctypes.c_int64286 # figure out size of _Py_ssize_t for Python 2:287 if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):288 _Py_ssize_t = ctypes.c_int64289 else:290 _Py_ssize_t = ctypes.c_int291 else:292 # platform ssize_t on Python 3280 _Py_ssize_t = ctypes.c_int293 _Py_ssize_t = ctypes.c_ssize_t294295 # regular python296 class _PyObject(ctypes.Structure):297 pass
53 unmodified lines