From 89983ec7b986caf2b00cf658bd6735131facb945 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 24 Feb 2009 14:27:40 +0100 Subject: [PATCH] clean up ref-counting for default arguments (by Lisandro) --- Cython/Compiler/Nodes.py | 2 +- tests/run/argdefault.pyx | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 -- 2.26.2