From: Thomas Waldmann Date: Fri, 17 May 2013 22:47:41 +0000 (+0200) Subject: utils: remove some old py compat code X-Git-Tag: 2.7~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07a7d551b5ff6ff61f96bd8d59e32c60098dc061;p=thirdparty%2Fjinja.git utils: remove some old py compat code --- diff --git a/jinja2/utils.py b/jinja2/utils.py index ca0968bf..b56c749e 100644 --- a/jinja2/utils.py +++ b/jinja2/utils.py @@ -45,29 +45,7 @@ missing = type('MissingType', (), {'__repr__': lambda x: 'missing'})() # internal code internal_code = set() - -# concatenate a list of strings and convert them to unicode. -# unfortunately there is a bug in python 2.4 and lower that causes -# unicode.join trash the traceback. -_concat = u''.join -try: - def _test_gen_bug(): - raise TypeError(_test_gen_bug) - yield None - _concat(_test_gen_bug()) -except TypeError as _error: - if not _error.args or _error.args[0] is not _test_gen_bug: - def concat(gen): - try: - return _concat(list(gen)) - except Exception: - # this hack is needed so that the current frame - # does not show up in the traceback. - exc_type, exc_value, tb = sys.exc_info() - six.reraise(exc_type, exc_value, tb.tb_next) - else: - concat = _concat - del _test_gen_bug, _error +concat = u''.join # if this python version is unable to deal with unicode filenames @@ -380,18 +358,10 @@ class LRUCache(object): # alias all queue methods for faster lookup self._popleft = self._queue.popleft self._pop = self._queue.pop - if hasattr(self._queue, 'remove'): - self._remove = self._queue.remove + self._remove = self._queue.remove self._wlock = allocate_lock() self._append = self._queue.append - def _remove(self, obj): - """Python 2.4 compatibility.""" - for idx, item in enumerate(self._queue): - if item == obj: - del self._queue[idx] - break - def __getstate__(self): return { 'capacity': self.capacity, @@ -605,15 +575,4 @@ except ImportError: from jinja2._markupsafe import Markup, escape, soft_unicode -# partials -try: - from functools import partial -except ImportError: - class partial(object): - def __init__(self, _func, *args, **kwargs): - self._func = _func - self._args = args - self._kwargs = kwargs - def __call__(self, *args, **kwargs): - kwargs.update(self._kwargs) - return self._func(*(self._args + args), **kwargs) +from functools import partial