From: Stefan Behnel Date: Tue, 24 Feb 2009 13:27:40 +0000 (+0100) Subject: clean up ref-counting for default arguments (by Lisandro) X-Git-Tag: 0.11.rc~43 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=89983ec7b986caf2b00cf658bd6735131facb945;p=cython.git clean up ref-counting for default arguments (by Lisandro) --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index d3558dbf..415814d0 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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) diff --git a/tests/run/argdefault.pyx b/tests/run/argdefault.pyx index 6e1b60bb..0a298f67 100644 --- a/tests/run/argdefault.pyx +++ b/tests/run/argdefault.pyx @@ -28,6 +28,11 @@ __doc__ = u""" >>> g5() #doctest: +ELLIPSIS + +>>> 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