]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Fixed a check that broke pypy
authorArmin Ronacher <armin.ronacher@active-4.com>
Sat, 18 May 2013 10:36:32 +0000 (11:36 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sat, 18 May 2013 10:36:32 +0000 (11:36 +0100)
jinja2/compiler.py

index 4ee39f89f793af71b78955fc2d3c297f74eae1cf..c3d84d1089030693f4ffd396287e5f12276f30b6 100644 (file)
@@ -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,