Your message dated Fri, 27 Aug 2010 20:07:01 +0200 with message-id <4C77FEC5.1070408@dogguy.org> and subject line Re: Bug#593948: unblock: jinja2/2.5.2-2 has caused the Debian Bug report #593948, regarding unblock: jinja2/2.5.2-2 to be marked as done. This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact owner@bugs.debian.org immediately.) -- 593948: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593948 Debian Bug Tracking System Contact owner@bugs.debian.org with problems
--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: unblock: jinja2/2.5.2-2
- From: Piotr Ożarowski <piotr@debian.org>
- Date: Sun, 22 Aug 2010 16:50:42 +0200
- Message-id: <[🔎] 20100822145042.GA21229@piotro.eu>
Package: release.debian.org Severity: normal User: release.debian.org@packages.debian.org Usertags: freeze-exception Please unblock package jinja2 it's a bugfix release (I skipped docs, examples and removed markupsafe¹ module from attached debdiff²) [¹] we use packaged python-markupsafe instead, already in Squeeze [²] debdiff jinja2_2.5-1.dsc jinja2_2.5.2-2.dsc | \ filterdiff -x '*/docs/*' -x '*/examples/*' -x '*/_markupsafe/*' unblock jinja2/2.5.2-2 -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores) Locale: LANG=pl_PL.UTF-8, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash -- Do you like the idea of time-based freezes? Mention it in your signature in all mails to debian-release@l.d.o to encourage Release Team!diff -Nru jinja2-2.5/CHANGES jinja2-2.5.2/CHANGES --- jinja2-2.5/CHANGES 2010-05-29 20:55:56.000000000 +0200 +++ jinja2-2.5.2/CHANGES 2010-08-18 11:10:38.000000000 +0200 @@ -1,6 +1,33 @@ Jinja2 Changelog ================ +Version 2.5.2 +------------- +(bugfix release, released on August 18th 2010) + +- improved setup.py script to better work with assumptions people + might still have from it (``--with-speedups``). +- fixed a packaging error that excluded the new debug support. + +Version 2.5.1 +------------- +(bugfix release, released on August 17th 2010) + +- StopIteration exceptions raised by functions called from templates + are now intercepted and converted to undefineds. This solves a + lot of debugging grief. (StopIteration is used internally to + abort template execution) +- improved performance of macro calls slightly. +- babel extraction can now properly extract newstyle gettext calls. +- using the variable `num` in newstyle gettext for something else + than the pluralize count will no longer raise a :exc:`KeyError`. +- removed builtin markup class and switched to markupsafe. For backwards + compatibility the pure Python implementation still exists but is + pulled from markupsafe by the Jinja2 developers. The debug support + went into a separate feature called "debugsupport" and is disabled + by default because it is only relevant for Python 2.4 +- fixed an issue with unary operators having the wrong precendence. + Version 2.5 ----------- (codename Incoherence, relased on May 29th 2010) diff -Nru jinja2-2.5/debian/changelog jinja2-2.5.2/debian/changelog --- jinja2-2.5/debian/changelog 2010-08-22 16:45:49.000000000 +0200 +++ jinja2-2.5.2/debian/changelog 2010-08-22 16:45:49.000000000 +0200 @@ -1,3 +1,21 @@ +jinja2 (2.5.2-2) unstable; urgency=low + + * Really remove _markupsafe + + -- Piotr Ożarowski <piotr@debian.org> Thu, 19 Aug 2010 09:24:47 +0200 + +jinja2 (2.5.2-1) unstable; urgency=low + + * New upstream release + - speedups module moved to separate package: MarkupSafe + * python-markupsafe added to Depends (jinja2._markupsafe removed from the + package) + * debian/control: python3-jinja2 binary package updated to latest changes in + dh_python3 + * Standards-version bumped to 3.9.1 (no other changes needed) + + -- Piotr Ożarowski <piotr@debian.org> Wed, 18 Aug 2010 11:29:44 +0200 + jinja2 (2.5-1) unstable; urgency=low * New upstream release diff -Nru jinja2-2.5/debian/control jinja2-2.5.2/debian/control --- jinja2-2.5/debian/control 2010-08-22 16:45:49.000000000 +0200 +++ jinja2-2.5.2/debian/control 2010-08-22 16:45:49.000000000 +0200 @@ -8,7 +8,7 @@ python3-all-dev, python3-all-dbg, python-setuptools (>= 0.6b3-1~), python3-setuptools Build-Depends-Indep: python-sphinx (>= 0.6), python-pygments -Standards-Version: 3.8.4 +Standards-Version: 3.9.1 Homepage: http://jinja.pocoo.org/2/ XS-Python-Version: >= 2.4 Vcs-Svn: svn://svn.debian.org/python-modules/packages/jinja2/trunk @@ -16,7 +16,7 @@ Package: python-jinja2 Architecture: any -Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} +Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, python-markupsafe Recommends: python-pkg-resources Provides: ${python:Provides} Suggests: python-jinja2-doc @@ -69,11 +69,10 @@ Package: python3-jinja2 Architecture: any -Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, python3.1 -Recommends: python-pkg-resources -Provides: ${python:Provides} -Suggests: python-jinja2-doc -XB-Python-Version: ${python:Versions} +Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, python3-markupsafe, python3.1 +Recommends: python3-pkg-resources +Provides: ${python3:Provides} +Suggests: python3-jinja2-doc Description: small but fast and easy to use stand-alone template engine Jinja2 is a template engine written in pure Python. It provides a Django inspired non-XML syntax but supports inline expressions and an optional diff -Nru jinja2-2.5/debian/copyright jinja2-2.5.2/debian/copyright --- jinja2-2.5/debian/copyright 2010-08-22 16:45:49.000000000 +0200 +++ jinja2-2.5.2/debian/copyright 2010-08-22 16:45:49.000000000 +0200 @@ -3,7 +3,7 @@ It was downloaded from http://pypi.python.org/pypi/Jinja2 -Copyright (c) 2009 by the Jinja Team, see AUTHORS for more details. +Copyright (c) 2009-2010 by the Jinja Team, see AUTHORS for more details. Some rights reserved. @@ -69,8 +69,8 @@ --------------------------------------------------------------- -The Debian packaging is © 2008-2009, Piotr Ożarowski <piotr@debian.org> and -is licensed under the BSD. +The Debian packaging is © 2008-2010, Piotr Ożarowski <piotr@debian.org> and +is licensed under the same license as Jinja2. On Debian systems, the complete text of the BSD License can be found in `/usr/share/common-licenses/BSD' diff -Nru jinja2-2.5/debian/rules jinja2-2.5.2/debian/rules --- jinja2-2.5/debian/rules 2010-08-22 16:45:49.000000000 +0200 +++ jinja2-2.5.2/debian/rules 2010-08-22 16:45:49.000000000 +0200 @@ -30,11 +30,11 @@ touch $@ build-python%: - python$* setup.py --with-speedups build + python$* setup.py --with-debugsupport build touch $@ build-debug-python%: - python$*-dbg setup.py --with-speedups build + python$*-dbg setup.py --with-debugsupport build touch $@ build-docs: @@ -46,13 +46,15 @@ touch $@ install-python%: build - python$* setup.py --with-speedups install $(py_setup_install_args) \ + python$* setup.py --with-debugsupport install $(py_setup_install_args) \ --skip-build --single-version-externally-managed --root $(call pkgdir,$*) sed -i -e 's,REPLACE_ME_WITH_PROPER_VERSION,$(VERSION),' $(call pkgdir,$*)$(call py_libdir,$*)/jinja2/__init__.py + rm -rf $(call pkgdir,$*)$(call py_libdir,$*)/jinja2/_markupsafe + rm -f $(call pkgdir,$*)$(call py_libdir,$*)/jinja2/_debugsupport.c touch $@ install-debug-python%: build - python$*-dbg setup.py --with-speedups install $(py_setup_install_args) \ + python$*-dbg setup.py --with-debugsupport install $(py_setup_install_args) \ --skip-build --single-version-externally-managed --root $(call pkgdir,$*)-dbg/ find $(call pkgdir,$*)-dbg/usr/ ! -type d ! -name '*_d\.so' -delete find $(call pkgdir,$*)-dbg/usr/ -depth -empty -delete diff -Nru jinja2-2.5/docs/extensions.rst jinja2-2.5.2/docs/extensions.rst diff -Nru jinja2-2.5/docs/faq.rst jinja2-2.5.2/docs/faq.rst diff -Nru jinja2-2.5/docs/intro.rst jinja2-2.5.2/docs/intro.rst diff -Nru jinja2-2.5/docs/templates.rst jinja2-2.5.2/docs/templates.rst diff -Nru jinja2-2.5/examples/bench.py jinja2-2.5.2/examples/bench.py diff -Nru jinja2-2.5/examples/profile.py jinja2-2.5.2/examples/profile.py diff -Nru jinja2-2.5/examples/rwbench/djangoext.py jinja2-2.5.2/examples/rwbench/djangoext.py Binary files /tmp/NpbD08VgxX/jinja2-2.5/examples/rwbench/djangoext.pyc and /tmp/ZmiIRk1ok5/jinja2-2.5.2/examples/rwbench/djangoext.pyc differ diff -Nru jinja2-2.5/examples/rwbench/rwbench.py jinja2-2.5.2/examples/rwbench/rwbench.py Binary files /tmp/NpbD08VgxX/jinja2-2.5/examples/rwbench/rwbench.pyc and /tmp/ZmiIRk1ok5/jinja2-2.5.2/examples/rwbench/rwbench.pyc differ diff -Nru jinja2-2.5/jinja2/compiler.py jinja2-2.5.2/jinja2/compiler.py --- jinja2-2.5/jinja2/compiler.py 2010-05-29 20:07:41.000000000 +0200 +++ jinja2-2.5.2/jinja2/compiler.py 2010-08-17 17:14:51.000000000 +0200 @@ -1223,8 +1223,6 @@ else: finalize = unicode - self.newline(node) - # if we are inside a frame that requires output checking, we do so outdent_later = False if frame.require_output_check: diff -Nru jinja2-2.5/jinja2/constants.py jinja2-2.5.2/jinja2/constants.py --- jinja2-2.5/jinja2/constants.py 2010-04-07 14:21:02.000000000 +0200 +++ jinja2-2.5.2/jinja2/constants.py 2010-08-17 17:14:51.000000000 +0200 @@ -30,261 +30,3 @@ tempus tincidunt torquent tortor tristique turpis ullamcorper ultrices ultricies urna ut varius vehicula vel velit venenatis vestibulum vitae vivamus viverra volutpat vulputate''' - - -#: a dict of all html entities + apos -HTML_ENTITIES = { - 'AElig': 198, - 'Aacute': 193, - 'Acirc': 194, - 'Agrave': 192, - 'Alpha': 913, - 'Aring': 197, - 'Atilde': 195, - 'Auml': 196, - 'Beta': 914, - 'Ccedil': 199, - 'Chi': 935, - 'Dagger': 8225, - 'Delta': 916, - 'ETH': 208, - 'Eacute': 201, - 'Ecirc': 202, - 'Egrave': 200, - 'Epsilon': 917, - 'Eta': 919, - 'Euml': 203, - 'Gamma': 915, - 'Iacute': 205, - 'Icirc': 206, - 'Igrave': 204, - 'Iota': 921, - 'Iuml': 207, - 'Kappa': 922, - 'Lambda': 923, - 'Mu': 924, - 'Ntilde': 209, - 'Nu': 925, - 'OElig': 338, - 'Oacute': 211, - 'Ocirc': 212, - 'Ograve': 210, - 'Omega': 937, - 'Omicron': 927, - 'Oslash': 216, - 'Otilde': 213, - 'Ouml': 214, - 'Phi': 934, - 'Pi': 928, - 'Prime': 8243, - 'Psi': 936, - 'Rho': 929, - 'Scaron': 352, - 'Sigma': 931, - 'THORN': 222, - 'Tau': 932, - 'Theta': 920, - 'Uacute': 218, - 'Ucirc': 219, - 'Ugrave': 217, - 'Upsilon': 933, - 'Uuml': 220, - 'Xi': 926, - 'Yacute': 221, - 'Yuml': 376, - 'Zeta': 918, - 'aacute': 225, - 'acirc': 226, - 'acute': 180, - 'aelig': 230, - 'agrave': 224, - 'alefsym': 8501, - 'alpha': 945, - 'amp': 38, - 'and': 8743, - 'ang': 8736, - 'apos': 39, - 'aring': 229, - 'asymp': 8776, - 'atilde': 227, - 'auml': 228, - 'bdquo': 8222, - 'beta': 946, - 'brvbar': 166, - 'bull': 8226, - 'cap': 8745, - 'ccedil': 231, - 'cedil': 184, - 'cent': 162, - 'chi': 967, - 'circ': 710, - 'clubs': 9827, - 'cong': 8773, - 'copy': 169, - 'crarr': 8629, - 'cup': 8746, - 'curren': 164, - 'dArr': 8659, - 'dagger': 8224, - 'darr': 8595, - 'deg': 176, - 'delta': 948, - 'diams': 9830, - 'divide': 247, - 'eacute': 233, - 'ecirc': 234, - 'egrave': 232, - 'empty': 8709, - 'emsp': 8195, - 'ensp': 8194, - 'epsilon': 949, - 'equiv': 8801, - 'eta': 951, - 'eth': 240, - 'euml': 235, - 'euro': 8364, - 'exist': 8707, - 'fnof': 402, - 'forall': 8704, - 'frac12': 189, - 'frac14': 188, - 'frac34': 190, - 'frasl': 8260, - 'gamma': 947, - 'ge': 8805, - 'gt': 62, - 'hArr': 8660, - 'harr': 8596, - 'hearts': 9829, - 'hellip': 8230, - 'iacute': 237, - 'icirc': 238, - 'iexcl': 161, - 'igrave': 236, - 'image': 8465, - 'infin': 8734, - 'int': 8747, - 'iota': 953, - 'iquest': 191, - 'isin': 8712, - 'iuml': 239, - 'kappa': 954, - 'lArr': 8656, - 'lambda': 955, - 'lang': 9001, - 'laquo': 171, - 'larr': 8592, - 'lceil': 8968, - 'ldquo': 8220, - 'le': 8804, - 'lfloor': 8970, - 'lowast': 8727, - 'loz': 9674, - 'lrm': 8206, - 'lsaquo': 8249, - 'lsquo': 8216, - 'lt': 60, - 'macr': 175, - 'mdash': 8212, - 'micro': 181, - 'middot': 183, - 'minus': 8722, - 'mu': 956, - 'nabla': 8711, - 'nbsp': 160, - 'ndash': 8211, - 'ne': 8800, - 'ni': 8715, - 'not': 172, - 'notin': 8713, - 'nsub': 8836, - 'ntilde': 241, - 'nu': 957, - 'oacute': 243, - 'ocirc': 244, - 'oelig': 339, - 'ograve': 242, - 'oline': 8254, - 'omega': 969, - 'omicron': 959, - 'oplus': 8853, - 'or': 8744, - 'ordf': 170, - 'ordm': 186, - 'oslash': 248, - 'otilde': 245, - 'otimes': 8855, - 'ouml': 246, - 'para': 182, - 'part': 8706, - 'permil': 8240, - 'perp': 8869, - 'phi': 966, - 'pi': 960, - 'piv': 982, - 'plusmn': 177, - 'pound': 163, - 'prime': 8242, - 'prod': 8719, - 'prop': 8733, - 'psi': 968, - 'quot': 34, - 'rArr': 8658, - 'radic': 8730, - 'rang': 9002, - 'raquo': 187, - 'rarr': 8594, - 'rceil': 8969, - 'rdquo': 8221, - 'real': 8476, - 'reg': 174, - 'rfloor': 8971, - 'rho': 961, - 'rlm': 8207, - 'rsaquo': 8250, - 'rsquo': 8217, - 'sbquo': 8218, - 'scaron': 353, - 'sdot': 8901, - 'sect': 167, - 'shy': 173, - 'sigma': 963, - 'sigmaf': 962, - 'sim': 8764, - 'spades': 9824, - 'sub': 8834, - 'sube': 8838, - 'sum': 8721, - 'sup': 8835, - 'sup1': 185, - 'sup2': 178, - 'sup3': 179, - 'supe': 8839, - 'szlig': 223, - 'tau': 964, - 'there4': 8756, - 'theta': 952, - 'thetasym': 977, - 'thinsp': 8201, - 'thorn': 254, - 'tilde': 732, - 'times': 215, - 'trade': 8482, - 'uArr': 8657, - 'uacute': 250, - 'uarr': 8593, - 'ucirc': 251, - 'ugrave': 249, - 'uml': 168, - 'upsih': 978, - 'upsilon': 965, - 'uuml': 252, - 'weierp': 8472, - 'xi': 958, - 'yacute': 253, - 'yen': 165, - 'yuml': 255, - 'zeta': 950, - 'zwj': 8205, - 'zwnj': 8204 -} diff -Nru jinja2-2.5/jinja2/debug.py jinja2-2.5.2/jinja2/debug.py --- jinja2-2.5/jinja2/debug.py 2010-04-07 14:21:02.000000000 +0200 +++ jinja2-2.5.2/jinja2/debug.py 2010-08-17 17:14:51.000000000 +0200 @@ -60,7 +60,7 @@ self.frames = frames def chain_frames(self): - """Chains the frames. Requires ctypes or the speedups extension.""" + """Chains the frames. Requires ctypes or the debugsupport extension.""" prev_tb = None for tb in self.frames: if prev_tb is not None: @@ -299,7 +299,7 @@ # try to get a tb_set_next implementation try: - from jinja2._speedups import tb_set_next + from jinja2._debugsupport import tb_set_next except ImportError: try: tb_set_next = _init_ugly_crap() diff -Nru jinja2-2.5/jinja2/_debugsupport.c jinja2-2.5.2/jinja2/_debugsupport.c --- jinja2-2.5/jinja2/_debugsupport.c 1970-01-01 01:00:00.000000000 +0100 +++ jinja2-2.5.2/jinja2/_debugsupport.c 2010-08-17 17:14:51.000000000 +0200 @@ -0,0 +1,78 @@ +/** + * jinja2._debugsupport + * ~~~~~~~~~~~~~~~~~~~~ + * + * C implementation of `tb_set_next`. + * + * :copyright: (c) 2010 by the Jinja Team. + * :license: BSD. + */ + +#include <Python.h> + + +static PyObject* +tb_set_next(PyObject *self, PyObject *args) +{ + PyTracebackObject *tb, *old; + PyObject *next; + + if (!PyArg_ParseTuple(args, "O!O:tb_set_next", &PyTraceBack_Type, &tb, &next)) + return NULL; + if (next == Py_None) + next = NULL; + else if (!PyTraceBack_Check(next)) { + PyErr_SetString(PyExc_TypeError, + "tb_set_next arg 2 must be traceback or None"); + return NULL; + } + else + Py_INCREF(next); + + old = tb->tb_next; + tb->tb_next = (PyTracebackObject*)next; + Py_XDECREF(old); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef module_methods[] = { + {"tb_set_next", (PyCFunction)tb_set_next, METH_VARARGS, + "Set the tb_next member of a traceback object."}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + + +#if PY_MAJOR_VERSION < 3 + +#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ +#define PyMODINIT_FUNC void +#endif +PyMODINIT_FUNC +init_debugsupport(void) +{ + Py_InitModule3("jinja2._debugsupport", module_methods, ""); +} + +#else /* Python 3.x module initialization */ + +static struct PyModuleDef module_definition = { + PyModuleDef_HEAD_INIT, + "jinja2._debugsupport", + NULL, + -1, + module_methods, + NULL, + NULL, + NULL, + NULL +}; + +PyMODINIT_FUNC +PyInit__debugsupport(void) +{ + return PyModule_Create(&module_definition); +} + +#endif diff -Nru jinja2-2.5/jinja2/ext.py jinja2-2.5.2/jinja2/ext.py --- jinja2-2.5/jinja2/ext.py 2010-05-29 22:25:38.000000000 +0200 +++ jinja2-2.5.2/jinja2/ext.py 2010-08-17 17:14:51.000000000 +0200 @@ -13,7 +13,7 @@ from collections import deque from jinja2 import nodes from jinja2.defaults import * -from jinja2.environment import get_spontaneous_environment +from jinja2.environment import Environment from jinja2.runtime import Undefined, concat from jinja2.exceptions import TemplateAssertionError, TemplateSyntaxError from jinja2.utils import contextfunction, import_string, Markup, next @@ -286,7 +286,8 @@ parser.fail('pluralize without variables', lineno) node = self._make_node(singular, plural, variables, plural_expr, - bool(referenced), num_called_num) + bool(referenced), + num_called_num and have_plural) node.set_lineno(lineno) return node @@ -326,7 +327,7 @@ vars_referenced, num_called_num): """Generates a useful node from the data provided.""" # no variables referenced? no need to escape for old style - # gettext invocations + # gettext invocations only if there are vars. if not vars_referenced and not self.environment.newstyle_gettext: singular = singular.replace('%%', '%') if plural: @@ -545,6 +546,10 @@ gettext call in one line of code and the matching comment in the same line or the line before. + .. versionchanged:: 2.5.1 + The `newstyle_gettext` flag can be set to `True` to enable newstyle + gettext calls. + :param fileobj: the file-like object the messages should be extracted from :param keywords: a list of keywords (i.e. function names) that should be recognized as translation functions @@ -563,7 +568,10 @@ if InternationalizationExtension not in extensions: extensions.add(InternationalizationExtension) - environment = get_spontaneous_environment( + def getbool(options, key, default=False): + options.get(key, str(default)).lower() in ('1', 'on', 'yes', 'true') + + environment = Environment( options.get('block_start_string', BLOCK_START_STRING), options.get('block_end_string', BLOCK_END_STRING), options.get('variable_start_string', VARIABLE_START_STRING), @@ -572,17 +580,15 @@ options.get('comment_end_string', COMMENT_END_STRING), options.get('line_statement_prefix') or LINE_STATEMENT_PREFIX, options.get('line_comment_prefix') or LINE_COMMENT_PREFIX, - str(options.get('trim_blocks', TRIM_BLOCKS)).lower() in \ - ('1', 'on', 'yes', 'true'), + getbool(options, 'trim_blocks', TRIM_BLOCKS), NEWLINE_SEQUENCE, frozenset(extensions), - # fill with defaults so that environments are shared - # with other spontaneus environments. The rest of the - # arguments are optimizer, undefined, finalize, autoescape, - # loader, cache size, auto reloading setting and the - # bytecode cache - True, Undefined, None, False, None, 0, False, None + cache_size=0, + auto_reload=False ) + if getbool(options, 'newstyle_gettext'): + environment.newstyle_gettext = True + source = fileobj.read().decode(options.get('encoding', 'utf-8')) try: node = environment.parse(source) diff -Nru jinja2-2.5/jinja2/filters.py jinja2-2.5.2/jinja2/filters.py --- jinja2-2.5/jinja2/filters.py 2010-05-23 23:00:52.000000000 +0200 +++ jinja2-2.5.2/jinja2/filters.py 2010-08-18 11:13:09.000000000 +0200 @@ -555,16 +555,10 @@ """ if not method in ('common', 'ceil', 'floor'): raise FilterArgumentError('method must be common, ceil or floor') - if precision < 0: - raise FilterArgumentError('precision must be a postive integer ' - 'or zero.') if method == 'common': return round(value, precision) func = getattr(math, method) - if precision: - return func(value * 10 * precision) / (10 * precision) - else: - return func(value) + return func(value * (10 ** precision)) / (10 ** precision) @environmentfilter diff -Nru jinja2-2.5/jinja2/lexer.py jinja2-2.5.2/jinja2/lexer.py --- jinja2-2.5/jinja2/lexer.py 2010-04-07 14:21:02.000000000 +0200 +++ jinja2-2.5.2/jinja2/lexer.py 2010-08-17 17:14:51.000000000 +0200 @@ -432,9 +432,10 @@ 'root': [ # directives (c('(.*?)(?:%s)' % '|'.join( - [r'(?P<raw_begin>(?:\s*%s\-|%s)\s*raw\s*%s)' % ( + [r'(?P<raw_begin>(?:\s*%s\-|%s)\s*raw\s*(?:\-%s\s*|%s))' % ( e(environment.block_start_string), e(environment.block_start_string), + e(environment.block_end_string), e(environment.block_end_string) )] + [ r'(?P<%s_begin>\s*%s\-|%s)' % (n, r, r) diff -Nru jinja2-2.5/jinja2/_markupsafe/_bundle.py jinja2-2.5.2/jinja2/_markupsafe/_bundle.py diff -Nru jinja2-2.5/jinja2/_markupsafe/_constants.py jinja2-2.5.2/jinja2/_markupsafe/_constants.py diff -Nru jinja2-2.5/jinja2/_markupsafe/__init__.py jinja2-2.5.2/jinja2/_markupsafe/__init__.py diff -Nru jinja2-2.5/jinja2/_markupsafe/_native.py jinja2-2.5.2/jinja2/_markupsafe/_native.py diff -Nru jinja2-2.5/jinja2/_markupsafe/tests.py jinja2-2.5.2/jinja2/_markupsafe/tests.py diff -Nru jinja2-2.5/jinja2/parser.py jinja2-2.5.2/jinja2/parser.py --- jinja2-2.5/jinja2/parser.py 2010-04-12 14:02:14.000000000 +0200 +++ jinja2-2.5.2/jinja2/parser.py 2010-08-17 17:14:51.000000000 +0200 @@ -370,7 +370,7 @@ target = self.parse_tuple(simplified=True, extra_end_rules=extra_end_rules) else: - target = self.parse_primary(with_postfix=False) + target = self.parse_primary() target.set_ctx('store') if not target.can_assign(): self.fail('can\'t assign to %r' % target.__class__. @@ -525,20 +525,22 @@ lineno = self.stream.current.lineno return left - def parse_unary(self): + def parse_unary(self, with_postfix=True): token_type = self.stream.current.type lineno = self.stream.current.lineno if token_type == 'sub': next(self.stream) - node = self.parse_unary() - return nodes.Neg(node, lineno=lineno) - if token_type == 'add': - next(self.stream) - node = self.parse_unary() - return nodes.Pos(node, lineno=lineno) - return self.parse_primary() + node = nodes.Neg(self.parse_unary(False), lineno=lineno) + elif token_type == 'add': + next(self.stream) + node = nodes.Pos(self.parse_unary(False), lineno=lineno) + else: + node = self.parse_primary() + if with_postfix: + node = self.parse_postfix(node) + return node - def parse_primary(self, with_postfix=True): + def parse_primary(self): token = self.stream.current if token.type == 'name': if token.value in ('true', 'false', 'True', 'False'): @@ -570,8 +572,6 @@ node = self.parse_dict() else: self.fail("unexpected '%s'" % describe_token(token), token.lineno) - if with_postfix: - node = self.parse_postfix(node) return node def parse_tuple(self, simplified=False, with_condexpr=True, @@ -596,7 +596,7 @@ """ lineno = self.stream.current.lineno if simplified: - parse = lambda: self.parse_primary(with_postfix=False) + parse = self.parse_primary elif with_condexpr: parse = self.parse_expression else: diff -Nru jinja2-2.5/jinja2/runtime.py jinja2-2.5.2/jinja2/runtime.py --- jinja2-2.5/jinja2/runtime.py 2010-05-29 21:16:29.000000000 +0200 +++ jinja2-2.5.2/jinja2/runtime.py 2010-08-17 17:14:51.000000000 +0200 @@ -179,7 +179,12 @@ args = (__self.eval_ctx,) + args elif getattr(__obj, 'environmentfunction', 0): args = (__self.environment,) + args - return __obj(*args, **kwargs) + try: + return __obj(*args, **kwargs) + except StopIteration: + return __self.environment.undefined('value was undefined because ' + 'a callable raised a ' + 'StopIteration exception') def derived(self, locals=None): """Internal helper function to create a derived context.""" @@ -345,7 +350,7 @@ class Macro(object): - """Wraps a macro.""" + """Wraps a macro function.""" def __init__(self, environment, func, name, arguments, defaults, catch_kwargs, catch_varargs, caller): @@ -361,20 +366,24 @@ @internalcode def __call__(self, *args, **kwargs): - arguments = [] - for idx, name in enumerate(self.arguments): - try: - value = args[idx] - except: + # try to consume the positional arguments + arguments = list(args[:self._argument_count]) + off = len(arguments) + + # if the number of arguments consumed is not the number of + # arguments expected we start filling in keyword arguments + # and defaults. + if off != self._argument_count: + for idx, name in enumerate(self.arguments[len(arguments):]): try: value = kwargs.pop(name) - except: + except KeyError: try: - value = self.defaults[idx - self._argument_count] - except: + value = self.defaults[idx - self._argument_count + off] + except IndexError: value = self._environment.undefined( 'parameter %r was not provided' % name, name=name) - arguments.append(value) + arguments.append(value) # it's important that the order of these arguments does not change # if not also changed in the compiler's `function_scoping` method. diff -Nru jinja2-2.5/jinja2/_speedups.c jinja2-2.5.2/jinja2/_speedups.c --- jinja2-2.5/jinja2/_speedups.c 2010-04-07 14:21:02.000000000 +0200 +++ jinja2-2.5.2/jinja2/_speedups.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,259 +0,0 @@ -/** - * jinja2._speedups - * ~~~~~~~~~~~~~~~~ - * - * This module implements functions for automatic escaping in C for better - * performance. Additionally it defines a `tb_set_next` function to patch the - * debug traceback. If the speedups module is not compiled a ctypes - * implementation of `tb_set_next` and Python implementations of the other - * functions are used. - * - * :copyright: (c) 2009 by the Jinja Team. - * :license: BSD. - */ - -#include <Python.h> - -#define ESCAPED_CHARS_TABLE_SIZE 63 -#define UNICHR(x) (((PyUnicodeObject*)PyUnicode_DecodeASCII(x, strlen(x), NULL))->str); - -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -#define PY_SSIZE_T_MAX INT_MAX -#define PY_SSIZE_T_MIN INT_MIN -#endif - - -static PyObject* markup; -static Py_ssize_t escaped_chars_delta_len[ESCAPED_CHARS_TABLE_SIZE]; -static Py_UNICODE *escaped_chars_repl[ESCAPED_CHARS_TABLE_SIZE]; - -static int -init_constants(void) -{ - PyObject *module; - /* happing of characters to replace */ - escaped_chars_repl['"'] = UNICHR("""); - escaped_chars_repl['\''] = UNICHR("'"); - escaped_chars_repl['&'] = UNICHR("&"); - escaped_chars_repl['<'] = UNICHR("<"); - escaped_chars_repl['>'] = UNICHR(">"); - - /* lengths of those characters when replaced - 1 */ - memset(escaped_chars_delta_len, 0, sizeof (escaped_chars_delta_len)); - escaped_chars_delta_len['"'] = escaped_chars_delta_len['\''] = \ - escaped_chars_delta_len['&'] = 4; - escaped_chars_delta_len['<'] = escaped_chars_delta_len['>'] = 3; - - /* import markup type so that we can mark the return value */ - module = PyImport_ImportModule("jinja2.utils"); - if (!module) - return 0; - markup = PyObject_GetAttrString(module, "Markup"); - Py_DECREF(module); - - return 1; -} - -static PyObject* -escape_unicode(PyUnicodeObject *in) -{ - PyUnicodeObject *out; - Py_UNICODE *inp = in->str; - const Py_UNICODE *inp_end = in->str + in->length; - Py_UNICODE *next_escp; - Py_UNICODE *outp; - Py_ssize_t delta=0, erepl=0, delta_len=0; - - /* First we need to figure out how long the escaped string will be */ - while (*(inp) || inp < inp_end) { - if (*inp < ESCAPED_CHARS_TABLE_SIZE && escaped_chars_delta_len[*inp]) { - delta += escaped_chars_delta_len[*inp]; - ++erepl; - } - ++inp; - } - - /* Do we need to escape anything at all? */ - if (!erepl) { - Py_INCREF(in); - return (PyObject*)in; - } - - out = (PyUnicodeObject*)PyUnicode_FromUnicode(NULL, in->length + delta); - if (!out) - return NULL; - - outp = out->str; - inp = in->str; - while (erepl-- > 0) { - /* look for the next substitution */ - next_escp = inp; - while (next_escp < inp_end) { - if (*next_escp < ESCAPED_CHARS_TABLE_SIZE && - (delta_len = escaped_chars_delta_len[*next_escp])) { - ++delta_len; - break; - } - ++next_escp; - } - - if (next_escp > inp) { - /* copy unescaped chars between inp and next_escp */ - Py_UNICODE_COPY(outp, inp, next_escp-inp); - outp += next_escp - inp; - } - - /* escape 'next_escp' */ - Py_UNICODE_COPY(outp, escaped_chars_repl[*next_escp], delta_len); - outp += delta_len; - - inp = next_escp + 1; - } - if (inp < inp_end) - Py_UNICODE_COPY(outp, inp, in->length - (inp - in->str)); - - return (PyObject*)out; -} - - -static PyObject* -escape(PyObject *self, PyObject *text) -{ - PyObject *s = NULL, *rv = NULL, *html; - - /* we don't have to escape integers, bools or floats */ - if (PyLong_CheckExact(text) || -#if PY_MAJOR_VERSION < 3 - PyInt_CheckExact(text) || -#endif - PyFloat_CheckExact(text) || PyBool_Check(text) || - text == Py_None) - return PyObject_CallFunctionObjArgs(markup, text, NULL); - - /* if the object has an __html__ method that performs the escaping */ - html = PyObject_GetAttrString(text, "__html__"); - if (html) { - rv = PyObject_CallObject(html, NULL); - Py_DECREF(html); - return rv; - } - - /* otherwise make the object unicode if it isn't, then escape */ - PyErr_Clear(); - if (!PyUnicode_Check(text)) { -#if PY_MAJOR_VERSION < 3 - PyObject *unicode = PyObject_Unicode(text); -#else - PyObject *unicode = PyObject_Str(text); -#endif - if (!unicode) - return NULL; - s = escape_unicode((PyUnicodeObject*)unicode); - Py_DECREF(unicode); - } - else - s = escape_unicode((PyUnicodeObject*)text); - - /* convert the unicode string into a markup object. */ - rv = PyObject_CallFunctionObjArgs(markup, (PyObject*)s, NULL); - Py_DECREF(s); - return rv; -} - - -static PyObject* -soft_unicode(PyObject *self, PyObject *s) -{ - if (!PyUnicode_Check(s)) -#if PY_MAJOR_VERSION < 3 - return PyObject_Unicode(s); -#else - return PyObject_Str(s); -#endif - Py_INCREF(s); - return s; -} - - -static PyObject* -tb_set_next(PyObject *self, PyObject *args) -{ - PyTracebackObject *tb, *old; - PyObject *next; - - if (!PyArg_ParseTuple(args, "O!O:tb_set_next", &PyTraceBack_Type, &tb, &next)) - return NULL; - if (next == Py_None) - next = NULL; - else if (!PyTraceBack_Check(next)) { - PyErr_SetString(PyExc_TypeError, - "tb_set_next arg 2 must be traceback or None"); - return NULL; - } - else - Py_INCREF(next); - - old = tb->tb_next; - tb->tb_next = (PyTracebackObject*)next; - Py_XDECREF(old); - - Py_INCREF(Py_None); - return Py_None; -} - - -static PyMethodDef module_methods[] = { - {"escape", (PyCFunction)escape, METH_O, - "escape(s) -> markup\n\n" - "Convert the characters &, <, >, ', and \" in string s to HTML-safe\n" - "sequences. Use this if you need to display text that might contain\n" - "such characters in HTML. Marks return value as markup string."}, - {"soft_unicode", (PyCFunction)soft_unicode, METH_O, - "soft_unicode(object) -> string\n\n" - "Make a string unicode if it isn't already. That way a markup\n" - "string is not converted back to unicode."}, - {"tb_set_next", (PyCFunction)tb_set_next, METH_VARARGS, - "Set the tb_next member of a traceback object."}, - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - - -#if PY_MAJOR_VERSION < 3 - -#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ -#define PyMODINIT_FUNC void -#endif -PyMODINIT_FUNC -init_speedups(void) -{ - if (!init_constants()) - return; - - Py_InitModule3("jinja2._speedups", module_methods, ""); -} - -#else /* Python 3.x module initialization */ - -static struct PyModuleDef module_definition = { - PyModuleDef_HEAD_INIT, - "jinja2._speedups", - NULL, - -1, - module_methods, - NULL, - NULL, - NULL, - NULL -}; - -PyMODINIT_FUNC -PyInit__speedups(void) -{ - if (!init_constants()) - return NULL; - - return PyModule_Create(&module_definition); -} - -#endif diff -Nru jinja2-2.5/jinja2/testsuite/api.py jinja2-2.5.2/jinja2/testsuite/api.py --- jinja2-2.5/jinja2/testsuite/api.py 2010-05-23 23:14:39.000000000 +0200 +++ jinja2-2.5.2/jinja2/testsuite/api.py 2010-08-17 17:14:51.000000000 +0200 @@ -172,6 +172,14 @@ class UndefinedTestCase(JinjaTestCase): + def test_stopiteration_is_undefined(self): + def test(): + raise StopIteration() + t = Template('A{{ test() }}B') + assert t.render(test=test) == 'AB' + t = Template('A{{ test().missingattribute }}B') + self.assert_raises(UndefinedError, t.render, test=test) + def test_default_undefined(self): env = Environment(undefined=Undefined) self.assert_equal(env.from_string('{{ missing }}').render(), u'') diff -Nru jinja2-2.5/jinja2/testsuite/ext.py jinja2-2.5.2/jinja2/testsuite/ext.py --- jinja2-2.5/jinja2/testsuite/ext.py 2010-05-29 22:30:54.000000000 +0200 +++ jinja2-2.5.2/jinja2/testsuite/ext.py 2010-08-17 17:14:51.000000000 +0200 @@ -51,7 +51,13 @@ 'stringformat.html': '{{ _("User: %(num)s", num=user_count) }}', 'ngettext.html': '{{ ngettext("%(num)s apple", "%(num)s apples", apples) }}', 'ngettext_long.html': '{% trans num=apples %}{{ num }} apple{% pluralize %}' - '{{ num }} apples{% endtrans %}' + '{{ num }} apples{% endtrans %}', + 'transvars1.html': '{% trans %}User: {{ num }}{% endtrans %}', + 'transvars2.html': '{% trans num=count %}User: {{ num }}{% endtrans %}', + 'transvars3.html': '{% trans count=num %}User: {{ count }}{% endtrans %}', + 'novars.html': '{% trans %}%(hello)s{% endtrans %}', + 'vars.html': '{% trans %}{{ foo }}%(foo)s{% endtrans %}', + 'explicitvars.html': '{% trans foo="42" %}%(foo)s{% endtrans %}' } @@ -62,6 +68,7 @@ 'One user online': u'Ein Benutzer online', '%(user_count)s users online': u'%(user_count)s Benutzer online', 'User: %(num)s': u'Benutzer: %(num)s', + 'User: %(count)s': u'Benutzer: %(count)s', '%(num)s apple': u'%(num)s Apfel', '%(num)s apples': u'%(num)s Äpfel' } @@ -345,6 +352,22 @@ assert re.search(r"l_ngettext, u?'\%\(num\)s apple', u?'\%\(num\)s " r"apples', 3", source) is not None + def test_trans_vars(self): + t1 = newstyle_i18n_env.get_template('transvars1.html') + t2 = newstyle_i18n_env.get_template('transvars2.html') + t3 = newstyle_i18n_env.get_template('transvars3.html') + assert t1.render(num=1, LANGUAGE='de') == 'Benutzer: 1' + assert t2.render(count=23, LANGUAGE='de') == 'Benutzer: 23' + assert t3.render(num=42, LANGUAGE='de') == 'Benutzer: 42' + + def test_novars_vars_escaping(self): + t = newstyle_i18n_env.get_template('novars.html') + assert t.render() == '%(hello)s' + t = newstyle_i18n_env.get_template('vars.html') + assert t.render(foo='42') == '42%(foo)s' + t = newstyle_i18n_env.get_template('explicitvars.html') + assert t.render() == '%(foo)s' + class AutoEscapeTestCase(JinjaTestCase): diff -Nru jinja2-2.5/jinja2/testsuite/filters.py jinja2-2.5.2/jinja2/testsuite/filters.py --- jinja2-2.5/jinja2/testsuite/filters.py 2010-05-23 23:02:27.000000000 +0200 +++ jinja2-2.5.2/jinja2/testsuite/filters.py 2010-08-17 17:14:51.000000000 +0200 @@ -206,13 +206,19 @@ def test_abs(self): tmpl = env.from_string('''{{ -1|abs }}|{{ 1|abs }}''') - return tmpl.render() == '1|1' + assert tmpl.render() == '1|1', tmpl.render() - def test_round(self): + def test_round_positive(self): tmpl = env.from_string('{{ 2.7|round }}|{{ 2.1|round }}|' - "{{ 2.1234|round(2, 'floor') }}|" + "{{ 2.1234|round(3, 'floor') }}|" "{{ 2.1|round(0, 'ceil') }}") - return tmpl.render() == '3.0|2.0|2.1|3.0' + assert tmpl.render() == '3.0|2.0|2.123|3.0', tmpl.render() + + def test_round_negative(self): + tmpl = env.from_string('{{ 21.3|round(-1)}}|' + "{{ 21.3|round(-1, 'ceil')}}|" + "{{ 21.3|round(-1, 'floor')}}") + assert tmpl.render() == '20.0|30.0|20.0',tmpl.render() def test_xmlattr(self): tmpl = env.from_string("{{ {'foo': 42, 'bar': 23, 'fish': none, " diff -Nru jinja2-2.5/jinja2/testsuite/lexnparse.py jinja2-2.5.2/jinja2/testsuite/lexnparse.py --- jinja2-2.5/jinja2/testsuite/lexnparse.py 2010-04-07 14:21:02.000000000 +0200 +++ jinja2-2.5.2/jinja2/testsuite/lexnparse.py 2010-08-17 17:14:51.000000000 +0200 @@ -16,7 +16,8 @@ from jinja2.testsuite import JinjaTestCase -from jinja2 import Environment, Template, TemplateSyntaxError, UndefinedError +from jinja2 import Environment, Template, TemplateSyntaxError, \ + UndefinedError, nodes env = Environment() @@ -36,6 +37,10 @@ '{%raw%}{{ bar }}|{% baz %}{% endraw %}') assert tmpl.render() == 'foo|{{ bar }}|{% baz %}' + def test_raw2(self): + tmpl = env.from_string('1 {%- raw -%} 2 {%- endraw -%} 3') + assert tmpl.render() == '123' + def test_balancing(self): env = Environment('{%', '%}', '${', '}') tmpl = env.from_string('''{% for item in seq @@ -353,6 +358,11 @@ '{{ none is defined }}|{{ missing is defined }}') assert tmpl.render() == 'True|False|None|True|False' + def test_neg_filter_priority(self): + node = env.parse('{{ -1|foo }}') + assert isinstance(node.body[0].nodes[0], nodes.Filter) + assert isinstance(node.body[0].nodes[0].node, nodes.Neg) + def test_const_assign(self): constass1 = '''{% set true = 42 %}''' constass2 = '''{% for none in seq %}{% endfor %}''' diff -Nru jinja2-2.5/jinja2/utils.py jinja2-2.5.2/jinja2/utils.py --- jinja2-2.5/jinja2/utils.py 2010-04-20 19:48:26.000000000 +0200 +++ jinja2-2.5.2/jinja2/utils.py 2010-08-17 17:14:51.000000000 +0200 @@ -349,205 +349,6 @@ return Markup(u'\n'.join(u'<p>%s</p>' % escape(x) for x in result)) -class Markup(unicode): - r"""Marks a string as being safe for inclusion in HTML/XML output without - needing to be escaped. This implements the `__html__` interface a couple - of frameworks and web applications use. :class:`Markup` is a direct - subclass of `unicode` and provides all the methods of `unicode` just that - it escapes arguments passed and always returns `Markup`. - - The `escape` function returns markup objects so that double escaping can't - happen. If you want to use autoescaping in Jinja just enable the - autoescaping feature in the environment. - - The constructor of the :class:`Markup` class can be used for three - different things: When passed an unicode object it's assumed to be safe, - when passed an object with an HTML representation (has an `__html__` - method) that representation is used, otherwise the object passed is - converted into a unicode string and then assumed to be safe: - - >>> Markup("Hello <em>World</em>!") - Markup(u'Hello <em>World</em>!') - >>> class Foo(object): - ... def __html__(self): - ... return '<a href="#">foo</a>' - ... - >>> Markup(Foo()) - Markup(u'<a href="#">foo</a>') - - If you want object passed being always treated as unsafe you can use the - :meth:`escape` classmethod to create a :class:`Markup` object: - - >>> Markup.escape("Hello <em>World</em>!") - Markup(u'Hello <em>World</em>!') - - Operations on a markup string are markup aware which means that all - arguments are passed through the :func:`escape` function: - - >>> em = Markup("<em>%s</em>") - >>> em % "foo & bar" - Markup(u'<em>foo & bar</em>') - >>> strong = Markup("<strong>%(text)s</strong>") - >>> strong % {'text': '<blink>hacker here</blink>'} - Markup(u'<strong><blink>hacker here</blink></strong>') - >>> Markup("<em>Hello</em> ") + "<foo>" - Markup(u'<em>Hello</em> <foo>') - """ - __slots__ = () - - def __new__(cls, base=u'', encoding=None, errors='strict'): - if hasattr(base, '__html__'): - base = base.__html__() - if encoding is None: - return unicode.__new__(cls, base) - return unicode.__new__(cls, base, encoding, errors) - - def __html__(self): - return self - - def __add__(self, other): - if hasattr(other, '__html__') or isinstance(other, basestring): - return self.__class__(unicode(self) + unicode(escape(other))) - return NotImplemented - - def __radd__(self, other): - if hasattr(other, '__html__') or isinstance(other, basestring): - return self.__class__(unicode(escape(other)) + unicode(self)) - return NotImplemented - - def __mul__(self, num): - if isinstance(num, (int, long)): - return self.__class__(unicode.__mul__(self, num)) - return NotImplemented - __rmul__ = __mul__ - - def __mod__(self, arg): - if isinstance(arg, tuple): - arg = tuple(imap(_MarkupEscapeHelper, arg)) - else: - arg = _MarkupEscapeHelper(arg) - return self.__class__(unicode.__mod__(self, arg)) - - def __repr__(self): - return '%s(%s)' % ( - self.__class__.__name__, - unicode.__repr__(self) - ) - - def join(self, seq): - return self.__class__(unicode.join(self, imap(escape, seq))) - join.__doc__ = unicode.join.__doc__ - - def split(self, *args, **kwargs): - return map(self.__class__, unicode.split(self, *args, **kwargs)) - split.__doc__ = unicode.split.__doc__ - - def rsplit(self, *args, **kwargs): - return map(self.__class__, unicode.rsplit(self, *args, **kwargs)) - rsplit.__doc__ = unicode.rsplit.__doc__ - - def splitlines(self, *args, **kwargs): - return map(self.__class__, unicode.splitlines(self, *args, **kwargs)) - splitlines.__doc__ = unicode.splitlines.__doc__ - - def unescape(self): - r"""Unescape markup again into an unicode string. This also resolves - known HTML4 and XHTML entities: - - >>> Markup("Main » <em>About</em>").unescape() - u'Main \xbb <em>About</em>' - """ - from jinja2.constants import HTML_ENTITIES - def handle_match(m): - name = m.group(1) - if name in HTML_ENTITIES: - return unichr(HTML_ENTITIES[name]) - try: - if name[:2] in ('#x', '#X'): - return unichr(int(name[2:], 16)) - elif name.startswith('#'): - return unichr(int(name[1:])) - except ValueError: - pass - return u'' - return _entity_re.sub(handle_match, unicode(self)) - - def striptags(self): - r"""Unescape markup into an unicode string and strip all tags. This - also resolves known HTML4 and XHTML entities. Whitespace is - normalized to one: - - >>> Markup("Main » <em>About</em>").striptags() - u'Main \xbb About' - """ - stripped = u' '.join(_striptags_re.sub('', self).split()) - return Markup(stripped).unescape() - - @classmethod - def escape(cls, s): - """Escape the string. Works like :func:`escape` with the difference - that for subclasses of :class:`Markup` this function would return the - correct subclass. - """ - rv = escape(s) - if rv.__class__ is not cls: - return cls(rv) - return rv - - def make_wrapper(name): - orig = getattr(unicode, name) - def func(self, *args, **kwargs): - args = _escape_argspec(list(args), enumerate(args)) - _escape_argspec(kwargs, kwargs.iteritems()) - return self.__class__(orig(self, *args, **kwargs)) - func.__name__ = orig.__name__ - func.__doc__ = orig.__doc__ - return func - - for method in '__getitem__', 'capitalize', \ - 'title', 'lower', 'upper', 'replace', 'ljust', \ - 'rjust', 'lstrip', 'rstrip', 'center', 'strip', \ - 'translate', 'expandtabs', 'swapcase', 'zfill': - locals()[method] = make_wrapper(method) - - # new in python 2.5 - if hasattr(unicode, 'partition'): - partition = make_wrapper('partition'), - rpartition = make_wrapper('rpartition') - - # new in python 2.6 - if hasattr(unicode, 'format'): - format = make_wrapper('format') - - # not in python 3 - if hasattr(unicode, '__getslice__'): - __getslice__ = make_wrapper('__getslice__') - - del method, make_wrapper - - -def _escape_argspec(obj, iterable): - """Helper for various string-wrapped functions.""" - for key, value in iterable: - if hasattr(value, '__html__') or isinstance(value, basestring): - obj[key] = escape(value) - return obj - - -class _MarkupEscapeHelper(object): - """Helper for Markup.__mod__""" - - def __init__(self, obj): - self.obj = obj - - __getitem__ = lambda s, x: _MarkupEscapeHelper(s.obj[x]) - __str__ = lambda s: str(escape(s.obj)) - __unicode__ = lambda s: unicode(escape(s.obj)) - __repr__ = lambda s: str(escape(repr(s.obj))) - __int__ = lambda s: int(s.obj) - __float__ = lambda s: float(s.obj) - - class LRUCache(object): """A simple LRU Cache implementation.""" @@ -776,33 +577,14 @@ return self.sep -# we have to import it down here as the speedups module imports the -# markup type which is define above. +# try markupsafe first, if that fails go with Jinja2's bundled version +# of markupsafe. Markupsafe was previously Jinja2's implementation of +# the Markup object but was moved into a separate package in a patchleve +# release try: - from jinja2._speedups import escape, soft_unicode + from markupsafe import Markup, escape, soft_unicode except ImportError: - def escape(s): - """Convert the characters &, <, >, ' and " in string s to HTML-safe - sequences. Use this if you need to display text that might contain - such characters in HTML. Marks return value as markup string. - """ - if hasattr(s, '__html__'): - return s.__html__() - return Markup(unicode(s) - .replace('&', '&') - .replace('>', '>') - .replace('<', '<') - .replace("'", ''') - .replace('"', '"') - ) - - def soft_unicode(s): - """Make a string unicode if it isn't already. That way a markup - string is not converted back to unicode. - """ - if not isinstance(s, unicode): - s = unicode(s) - return s + from jinja2._markupsafe import Markup, escape, soft_unicode # partials diff -Nru jinja2-2.5/Jinja2.egg-info/PKG-INFO jinja2-2.5.2/Jinja2.egg-info/PKG-INFO --- jinja2-2.5/Jinja2.egg-info/PKG-INFO 2010-05-29 22:54:35.000000000 +0200 +++ jinja2-2.5.2/Jinja2.egg-info/PKG-INFO 2010-08-18 11:15:03.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: Jinja2 -Version: 2.5 +Version: 2.5.2 Summary: A small but fast and easy to use stand-alone template engine written in pure python. Home-page: http://jinja.pocoo.org/ Author: Armin Ronacher diff -Nru jinja2-2.5/Jinja2.egg-info/SOURCES.txt jinja2-2.5.2/Jinja2.egg-info/SOURCES.txt --- jinja2-2.5/Jinja2.egg-info/SOURCES.txt 2010-05-29 22:54:35.000000000 +0200 +++ jinja2-2.5.2/Jinja2.egg-info/SOURCES.txt 2010-08-18 11:15:03.000000000 +0200 @@ -113,7 +113,9 @@ examples/basic/templates/broken.html examples/basic/templates/subbroken.html examples/rwbench/djangoext.py +examples/rwbench/djangoext.pyc examples/rwbench/rwbench.py +examples/rwbench/rwbench.pyc examples/rwbench/django/_form.html examples/rwbench/django/_input_field.html examples/rwbench/django/_textarea.html @@ -140,7 +142,7 @@ ext/django2jinja/templates/layout.html ext/django2jinja/templates/subtemplate.html jinja2/__init__.py -jinja2/_speedups.c +jinja2/_debugsupport.c jinja2/_stringdefs.py jinja2/bccache.py jinja2/compiler.py @@ -162,6 +164,11 @@ jinja2/tests.py jinja2/utils.py jinja2/visitor.py +jinja2/_markupsafe/__init__.py +jinja2/_markupsafe/_bundle.py +jinja2/_markupsafe/_constants.py +jinja2/_markupsafe/_native.py +jinja2/_markupsafe/tests.py jinja2/testsuite/__init__.py jinja2/testsuite/api.py jinja2/testsuite/core_tags.py diff -Nru jinja2-2.5/MANIFEST.in jinja2-2.5.2/MANIFEST.in --- jinja2-2.5/MANIFEST.in 2010-05-23 23:23:37.000000000 +0200 +++ jinja2-2.5.2/MANIFEST.in 2010-08-18 11:10:00.000000000 +0200 @@ -1,4 +1,4 @@ -include MANIFEST.in Makefile CHANGES LICENSE AUTHORS jinja2/_speedups.c +include MANIFEST.in Makefile CHANGES LICENSE AUTHORS jinja2/_debugsupport.c recursive-include docs * recursive-include custom_fixers * recursive-include ext * diff -Nru jinja2-2.5/PKG-INFO jinja2-2.5.2/PKG-INFO --- jinja2-2.5/PKG-INFO 2010-05-29 22:54:35.000000000 +0200 +++ jinja2-2.5.2/PKG-INFO 2010-08-18 11:15:04.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: Jinja2 -Version: 2.5 +Version: 2.5.2 Summary: A small but fast and easy to use stand-alone template engine written in pure python. Home-page: http://jinja.pocoo.org/ Author: Armin Ronacher diff -Nru jinja2-2.5/setup.py jinja2-2.5.2/setup.py --- jinja2-2.5/setup.py 2010-05-29 22:53:58.000000000 +0200 +++ jinja2-2.5.2/setup.py 2010-08-18 11:14:23.000000000 +0200 @@ -43,6 +43,16 @@ import sys from setuptools import setup, Extension, Feature +from distutils.command.build_ext import build_ext + +debugsupport = Feature( + 'optional C debug support', + standard=False, + ext_modules = [ + Extension('jinja2._debugsupport', ['jinja2/_debugsupport.c']), + ], +) + # tell distribute to use 2to3 with our own fixers. extra = {} @@ -52,10 +62,25 @@ use_2to3_fixers=['custom_fixers'] ) +# ignore the old '--with-speedups' flag +try: + speedups_pos = sys.argv.index('--with-speedups') +except ValueError: + pass +else: + sys.argv[speedups_pos] = '--with-debugsupport' + sys.stderr.write('*' * 74 + '\n') + sys.stderr.write('WARNING:\n') + sys.stderr.write(' the --with-speedups flag is deprecated, assuming ' + '--with-debugsupport\n') + sys.stderr.write(' For the actual speedups install the MarkupSafe ' + 'package.\n') + sys.stderr.write('*' * 74 + '\n') + setup( name='Jinja2', - version='2.5', + version='2.5.2', url='http://jinja.pocoo.org/', license='BSD', author='Armin Ronacher', @@ -77,15 +102,8 @@ 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Text Processing :: Markup :: HTML' ], - packages=['jinja2', 'jinja2.testsuite', 'jinja2.testsuite.res'], - features={ - 'speedups': Feature("optional C speed-enhancements", - standard=False, - ext_modules=[ - Extension('jinja2._speedups', ['jinja2/_speedups.c']) - ] - ) - }, + packages=['jinja2', 'jinja2.testsuite', 'jinja2.testsuite.res', + 'jinja2._markupsafe'], extras_require={'i18n': ['Babel>=0.8']}, test_suite='jinja2.testsuite.suite', include_package_data=True, @@ -93,5 +111,6 @@ [babel.extractors] jinja2 = jinja2.ext:babel_extract[i18n] """, + features={'debugsupport': debugsupport}, **extra )Attachment: signature.asc
Description: Digital signature
--- End Message ---
--- Begin Message ---
- To: Piotr Ożarowski <piotr@debian.org>, 593948-done@bugs.debian.org
- Subject: Re: Bug#593948: unblock: jinja2/2.5.2-2
- From: Mehdi Dogguy <mehdi@dogguy.org>
- Date: Fri, 27 Aug 2010 20:07:01 +0200
- Message-id: <4C77FEC5.1070408@dogguy.org>
- In-reply-to: <[🔎] 20100822145042.GA21229@piotro.eu>
- References: <[🔎] 20100822145042.GA21229@piotro.eu>
On 08/22/2010 04:50 PM, Piotr Ożarowski wrote: > Package: release.debian.org > Severity: normal > User: release.debian.org@packages.debian.org > Usertags: freeze-exception > > Please unblock package jinja2 > Unblocked. Regards, -- Mehdi Dogguy مهدي الدڤي http://dogguy.org/
--- End Message ---