clean up ref-counting for default arguments (by Lisandro)
authorStefan Behnel <scoder@users.berlios.de>
Tue, 24 Feb 2009 13:27:40 +0000 (14:27 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Tue, 24 Feb 2009 13:27:40 +0000 (14:27 +0100)
Cython/Compiler/Nodes.py
tests/run/argdefault.pyx

index d3558dbf7ccd5c3170f41e7e0fe40d3a076aef23..415814d000d542acf84e0306592750e140db2b06 100644 (file)
@@ -1241,7 +1241,7 @@ class FuncDefNode(StatNode, BlockNode):
                     if default.is_temp and default.type.is_pyobject:
                         code.putln("%s = 0;" % default.result())
                     default.free_temps(code)
-                    code.put_giveref(arg.default_entry.cname)
+                    code.put_var_giveref(arg.default_entry)
         # For Python class methods, create and store function object
         if self.assmt:
             self.assmt.generate_execution_code(code)
index 6e1b60bb13b495153493034eff35ea4996920491..0a298f673ec99a83fc3ab4c5e2d54e7b39eab139 100644 (file)
@@ -28,6 +28,11 @@ __doc__ = u"""
 <argdefault.Bla object at ...>
 >>> g5() #doctest: +ELLIPSIS
 <argdefault.Bla object at ...>
+
+>>> f6()
+7
+>>> g6()
+7
 """
 
 GLB0 = (1, 2)
@@ -76,3 +81,10 @@ def f5(Bla arg=GLB5):
     return arg
 def g5(Bla arg=Bla()):
     return arg
+
+
+cdef int GLB6 = 7
+def f6(int arg=GLB6):
+    return arg
+def g6(int arg=7):
+    return arg