From: Armin Ronacher Date: Sat, 18 May 2013 10:36:32 +0000 (+0100) Subject: Fixed a check that broke pypy X-Git-Tag: 2.7~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dd7fadce7d9ce20a990aa2213b242a90d898183;p=thirdparty%2Fjinja.git Fixed a check that broke pypy --- diff --git a/jinja2/compiler.py b/jinja2/compiler.py index 4ee39f89..c3d84d10 100644 --- a/jinja2/compiler.py +++ b/jinja2/compiler.py @@ -53,7 +53,11 @@ def unoptimize_before_dead_code(): def f(): if 0: dummy(x) return f -unoptimize_before_dead_code = bool(unoptimize_before_dead_code().__closure__) + +# The getattr is necessary for pypy which does not set this attribute if +# no closure is on the function +unoptimize_before_dead_code = bool( + getattr(unoptimize_before_dead_code(), '__closure__', None)) def generate(node, environment, name, filename, stream=None,