fix refnanny for closure variable assignments
authorStefan Behnel <scoder@users.berlios.de>
Wed, 29 Apr 2009 17:53:23 +0000 (19:53 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 29 Apr 2009 17:53:23 +0000 (19:53 +0200)
Cython/Compiler/ExprNodes.py
tests/run/closures_T82.pyx

index de4a5bd3ecc5fc6857210c01f713988b51d30e7e..dc405545cda76d42035d5b4776d9014ca118c117 100644 (file)
@@ -1206,6 +1206,8 @@ class NameNode(AtomicExprNode):
                 if entry.is_cglobal:
                     code.put_giveref(rhs.py_result())
             code.putln('%s = %s;' % (self.result(), rhs.result_as(self.ctype())))
+            if self.type.is_pyobject and self.entry.in_closure:
+                code.put_giveref(self.result())
             if debug_disposal_code:
                 print("NameNode.generate_assignment_code:")
                 print("...generating post-assignment code for %s" % rhs)
index 45f087852ccbcc52fa4fdc515a1cc7dafeaea439..2a53056e49941f51668111a3a35932ff47138447 100644 (file)
@@ -73,13 +73,13 @@ def inner_override(a,b):
 def reassign(x):
     def f(a):
         return a+x
-    x = 1 # currently lacks a GIVEREF()
+    x = 1
     return f
 
 def reassign_int(x):
     def f(int a):
         return a+x
-    x = 1 # currently lacks a GIVEREF()
+    x = 1
     return f
 
 def reassign_int_int(int x):
@@ -100,15 +100,15 @@ def cy_twofuncs(x):
 
 def more_inner_funcs(x):
     # pretty ugly segfault
-    def f(a): # this lacks a GIVEREF()
+    def f(a):
         def g(b):
             return a+b+x
         return g
-    def g(b): # this lacks a GIVEREF()
+    def g(b):
         def f(a):
             return a+b+x
         return f
-    def h(b): # this lacks a GIVEREF()
+    def h(b):
         def f(a):
             return a+b+x
         return f