summaryrefslogtreecommitdiffstats
path: root/third_party/jinja2/debug.py
diff options
context:
space:
mode:
authornbarth@chromium.org <nbarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 09:48:34 +0000
committernbarth@chromium.org <nbarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 09:48:34 +0000
commite6e0570955d4fdf7f3e077124ce520b397680ff9 (patch)
tree75f716c55a2277ca48707d513dd4b4409a5dcd4b /third_party/jinja2/debug.py
parentaa5272de95c5933f48dee31aa409820da4c00667 (diff)
downloadchromium_src-e6e0570955d4fdf7f3e077124ce520b397680ff9.zip
chromium_src-e6e0570955d4fdf7f3e077124ce520b397680ff9.tar.gz
chromium_src-e6e0570955d4fdf7f3e077124ce520b397680ff9.tar.bz2
Update Jinja2 (Python template library) to 2.7.1
Jinja2 (used in Blink scripts in Source/core and Source/bindings) has been updated to 2.7.1 (from existing 2.6); see changelog. http://jinja.pocoo.org/docs/changelog/ The specific new features in this release that are useful are: * keep_trailing_newline * lstrip_blocks ...which make it easier to control whitespace, making templates easier to read. (Specifically it lets us easily indent control blocks.) * selectattr (allows filtering lists in template, simplifying Python code) In the Changelog these are referred to as: Added support for keeping the trailing newline in templates. Added finer grained support for stripping whitespace on the left side of blocks. Added map, select, reject, selectattr and rejectattr filters. BTW, 2.7 is the first Jinja2 major release in 2 years; 2.7.1 is a bugfix release: 2.7 2013-05-20 2.7.1 2013-08-07 This upgrade introduces a new dependency (on Windows), due to the safe string class being factored out into a separate library. Thus depends on separate CL: Add MarkupSafe library to third_party (dependency for Jinja2 2.7) https://codereview.chromium.org/23445019/ This has been committed as r221578: https://src.chromium.org/viewvc/chrome?view=rev&revision=221578 TBR=cpu@chromium.org Review URL: https://chromiumcodereview.appspot.com/23506004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221663 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/jinja2/debug.py')
-rw-r--r--third_party/jinja2/debug.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/third_party/jinja2/debug.py b/third_party/jinja2/debug.py
index 2af2222..815cc18 100644
--- a/third_party/jinja2/debug.py
+++ b/third_party/jinja2/debug.py
@@ -13,8 +13,9 @@
import sys
import traceback
from types import TracebackType
-from jinja2.utils import CodeType, missing, internal_code
+from jinja2.utils import missing, internal_code
from jinja2.exceptions import TemplateSyntaxError
+from jinja2._compat import iteritems, reraise, code_type
# on pypy we can take advantage of transparent proxies
try:
@@ -25,7 +26,7 @@ except ImportError:
# how does the raise helper look like?
try:
- exec "raise TypeError, 'foo'"
+ exec("raise TypeError, 'foo'")
except SyntaxError:
raise_helper = 'raise __jinja_exception__[1]'
except TypeError:
@@ -77,7 +78,7 @@ def make_frame_proxy(frame):
class ProcessedTraceback(object):
- """Holds a Jinja preprocessed traceback for priting or reraising."""
+ """Holds a Jinja preprocessed traceback for printing or reraising."""
def __init__(self, exc_type, exc_value, frames):
assert frames, 'no frames for this traceback?'
@@ -158,7 +159,7 @@ def translate_exception(exc_info, initial_skip=0):
frames = []
# skip some internal frames if wanted
- for x in xrange(initial_skip):
+ for x in range(initial_skip):
if tb is not None:
tb = tb.tb_next
initial_tb = tb
@@ -189,7 +190,7 @@ def translate_exception(exc_info, initial_skip=0):
# reraise it unchanged.
# XXX: can we backup here? when could this happen?
if not frames:
- raise exc_info[0], exc_info[1], exc_info[2]
+ reraise(exc_info[0], exc_info[1], exc_info[2])
return ProcessedTraceback(exc_info[0], exc_info[1], frames)
@@ -206,7 +207,7 @@ def fake_exc_info(exc_info, filename, lineno):
locals = ctx.get_all()
else:
locals = {}
- for name, value in real_locals.iteritems():
+ for name, value in iteritems(real_locals):
if name.startswith('l_') and value is not missing:
locals[name[2:]] = value
@@ -244,17 +245,17 @@ def fake_exc_info(exc_info, filename, lineno):
location = 'block "%s"' % function[6:]
else:
location = 'template'
- 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, (), ())
+ 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:
pass
# execute the code and catch the new traceback
try:
- exec code in globals, locals
+ exec(code, globals, locals)
except:
exc_info = sys.exc_info()
new_tb = exc_info[2].tb_next
@@ -330,10 +331,7 @@ def _init_ugly_crap():
tb_set_next = None
if tproxy is None:
try:
- from jinja2._debugsupport import tb_set_next
- except ImportError:
- try:
- tb_set_next = _init_ugly_crap()
- except:
- pass
+ tb_set_next = _init_ugly_crap()
+ except:
+ pass
del _init_ugly_crap