From: Thomas Waldmann Date: Sat, 18 May 2013 11:08:53 +0000 (+0200) Subject: new jinja2._compat module for stuff not yet in six 1.3.0 X-Git-Tag: 2.7~65^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2cf1d31ea7b1f69e8418dd534af31074e90ed2d;p=thirdparty%2Fjinja.git new jinja2._compat module for stuff not yet in six 1.3.0 --- diff --git a/jinja2/_compat.py b/jinja2/_compat.py new file mode 100644 index 00000000..61619a89 --- /dev/null +++ b/jinja2/_compat.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +""" + jinja2._compat + ~~~~~~~~~~~~~~ + + Some py2/py3 compatibility support that is not yet available in "six". + There are bugs open for "six" for all this stuff, so we can remove it + again from here as soon as we require a new enough "six" release. + + :copyright: Copyright 2013 by the Jinja team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +# https://bitbucket.org/gutworth/six/issue/25/add-unichr +try: + unichr = unichr # py2 +except NameError: + unichr = chr # py3 diff --git a/jinja2/_markupsafe/__init__.py b/jinja2/_markupsafe/__init__.py index b14d279d..49775f65 100644 --- a/jinja2/_markupsafe/__init__.py +++ b/jinja2/_markupsafe/__init__.py @@ -12,10 +12,7 @@ import re import six from six.moves import map from six.moves import zip -try: - unichr = unichr # py2 -except NameError: - unichr = chr # py3 +from jinja2._compat import unichr __all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent'] diff --git a/jinja2/_stringdefs.py b/jinja2/_stringdefs.py index 1161b7f4..da5830e9 100644 --- a/jinja2/_stringdefs.py +++ b/jinja2/_stringdefs.py @@ -13,6 +13,8 @@ :license: BSD, see LICENSE for details. """ +from jinja2._compat import unichr + Cc = u'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f' Cf = u'\xad\u0600\u0601\u0602\u0603\u06dd\u070f\u17b4\u17b5\u200b\u200c\u200d\u200e\u200f\u202a\u202b\u202c\u202d\u202e\u2060\u2061\u2062\u2063\u206a\u206b\u206c\u206d\u206e\u206f\ufeff\ufff9\ufffa\ufffb'