From: Armin Ronacher Date: Mon, 28 Apr 2008 18:49:51 +0000 (+0200) Subject: added python2.4 workaround for unicode.join bug X-Git-Tag: 2.0rc1~119 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1ae4fdfc72d5a88957ccc16a9ad134a8c7e5423d;p=jinja2.git added python2.4 workaround for unicode.join bug --HG-- branch : trunk --- diff --git a/jinja2/runtime.py b/jinja2/runtime.py index b289500..0aad4bd 100644 --- a/jinja2/runtime.py +++ b/jinja2/runtime.py @@ -8,6 +8,7 @@ :copyright: Copyright 2008 by Armin Ronacher. :license: GNU GPL. """ +import sys from types import FunctionType from itertools import chain, imap from jinja2.utils import Markup, partial, soft_unicode, escape @@ -25,7 +26,24 @@ missing = type('MissingType', (), {'__repr__': lambda x: 'missing'})() # concatenate a list of strings and convert them to unicode. -concat = u''.join +# unfortunately there is a bug in python 2.4 and lower that causes +# unicode.join trash the traceback. +try: + def _test_gen_bug(): + raise TypeError(_test_gen_bug) + yield None + u''.join(_test_gen_bug()) +except TypeError, e: + if e.args and e.args[0] is _test_gen_bug: + concat = u''.join + else: + def concat(gen): + try: + return u''.join(list(gen())) + except: + exc_type, exc_value, tb = sys.exc_info() + raise exc_type, exc_value, tb.tb_next +del _test_gen_bug def markup_join(*args):