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
Provenance
- Commit
07a7d55- Tree
1e6ea9e- Author
Thomas Waldmann <tw@waldmann-edv.de>- Committer
Thomas Waldmann <tw@waldmann-edv.de>- Parent
d2dbe10
1 file changed+3 added−44 removed
modified:jinja2/utils.py+3 added-44 removed
43 unmodified lines44 45 # internal code46 internal_code = set()47 48+concat = u''.join49 49-# 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''.join53-try:54- def _test_gen_bug():55- raise TypeError(_test_gen_bug)56- yield None57- _concat(_test_gen_bug())58-except 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, _error50 72-51 # 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 in302 unmodified lines357 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.append364 388- 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- break394-365 def __getstate__(self):366 return {367 'capacity': self.capacity,368 '_mapping': self._mapping,205 unmodified lines574 except ImportError:575 from jinja2._markupsafe import Markup, escape, soft_unicode576 577 608-# partials609-try:610- from functools import partial578+from functools import partial611-except 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)