]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
utils: remove some old py compat code
authorThomas Waldmann <tw@waldmann-edv.de>
Fri, 17 May 2013 22:47:41 +0000 (00:47 +0200)
committerThomas Waldmann <tw@waldmann-edv.de>
Fri, 17 May 2013 22:47:41 +0000 (00:47 +0200)
jinja2/utils.py

index ca0968bf41702933b7f9b9e70d4a568b3fba7b8f..b56c749e48c20fe17727757d3736048e5f8d66be 100644 (file)
@@ -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