Commit fa08b5db authored by Craig Citro's avatar Craig Citro

Fix bug in Cython closures branch.

parent 036a1810
......@@ -1181,7 +1181,7 @@ class FuncDefNode(StatNode, BlockNode):
for entry in lenv.var_entries:
if lenv.control_flow.get_state((entry.name, 'initalized')) is not True:
entry.xdecref_cleanup = 1
if self.needs_closure:
code.put_decref(Naming.cur_scope_cname, lenv.scope_class.type)
for entry in lenv.var_entries:
......@@ -1189,11 +1189,13 @@ class FuncDefNode(StatNode, BlockNode):
code.put_var_decref(entry)
# Decref any increfed args
for entry in lenv.arg_entries:
if (entry.type.is_pyobject
and not entry.in_closure
and lenv.control_flow.get_state((entry.name, 'source')) != 'arg'):
code.put_var_decref(entry)
if entry.type.is_pyobject:
src = lenv.control_flow.get_state((entry.name, 'source'))
if entry.in_closure and src == 'arg':
code.put_var_incref(entry)
elif not entry.in_closure and src != 'arg':
code.put_var_decref(entry)
# ----- Return
# This code is duplicated in ModuleNode.generate_module_init_func
if not lenv.nogil:
......
......@@ -3,6 +3,10 @@ __doc__ = u"""
>>> f(2)
5
>>> f = add_n(1000000)
>>> f(1000000), f(-1000000)
2000000, 0
>>> a(5)()
8
......
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