Commit 89983ec7 authored by Stefan Behnel's avatar Stefan Behnel

clean up ref-counting for default arguments (by Lisandro)

parent 4b6142dc
......@@ -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)
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment