Skip to content
Myr

utils: remove some old py compat code

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

authored by Thomas Waldmann · committed by Thomas Waldmann · parent d2dbe10 · Browse files · 1 file+3 added−44 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+3 added−44 removed

  • other:+3 added−44 removed

1 file+3 added−44 removed

modified:jinja2/utils.py+3 added-44 removed
43 unmodified lines
4445# internal code46internal_code = set()4748concat = u''.join4949# concatenate a list of strings and convert them to unicode.50# unfortunately there is a bug in python 2.4 and lower that causes51# unicode.join trash the traceback.52_concat = u''.join53try:54 def _test_gen_bug():55 raise TypeError(_test_gen_bug)56 yield None57 _concat(_test_gen_bug())58except TypeError as _error:59 if not _error.args or _error.args[0] is not _test_gen_bug:60 def concat(gen):61 try:62 return _concat(list(gen))63 except Exception:64 # this hack is needed so that the current frame65 # does not show up in the traceback.66 exc_type, exc_value, tb = sys.exc_info()67 six.reraise(exc_type, exc_value, tb.tb_next)68 else:69 concat = _concat70 del _test_gen_bug, _error507251# if this python version is unable to deal with unicode filenames52# when passed to encode we let this function encode it properly.53# This is used in a couple of places. As far as Jinja is concerned54# filenames are unicode *or* bytestrings in 2.x and unicode only in
302 unmodified lines
357 def _postinit(self):358 # alias all queue methods for faster lookup359 self._popleft = self._queue.popleft360 self._pop = self._queue.pop383 if hasattr(self._queue, 'remove'):384 self._remove = self._queue.remove361 self._remove = self._queue.remove362 self._wlock = allocate_lock()363 self._append = self._queue.append364388 def _remove(self, obj):389 """Python 2.4 compatibility."""390 for idx, item in enumerate(self._queue):391 if item == obj:392 del self._queue[idx]393 break394365 def __getstate__(self):366 return {367 'capacity': self.capacity,368 '_mapping': self._mapping,
205 unmodified lines
574except ImportError:575 from jinja2._markupsafe import Markup, escape, soft_unicode576577608# partials609try:610 from functools import partial578from functools import partial611except ImportError:612 class partial(object):613 def __init__(self, _func, *args, **kwargs):614 self._func = _func615 self._args = args616 self._kwargs = kwargs617 def __call__(self, *args, **kwargs):618 kwargs.update(self._kwargs)619 return self._func(*(self._args + args), **kwargs)