From 9423a65fb2c198ebbfaa00a1aa4ca392ae50b67f Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 29 Apr 2009 19:53:23 +0200 Subject: [PATCH] fix refnanny for closure variable assignments --- Cython/Compiler/ExprNodes.py | 2 ++ tests/run/closures_T82.pyx | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index de4a5bd3..dc405545 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1206,6 +1206,8 @@ class NameNode(AtomicExprNode): if entry.is_cglobal: code.put_giveref(rhs.py_result()) code.putln('%s = %s;' % (self.result(), rhs.result_as(self.ctype()))) + if self.type.is_pyobject and self.entry.in_closure: + code.put_giveref(self.result()) if debug_disposal_code: print("NameNode.generate_assignment_code:") print("...generating post-assignment code for %s" % rhs) diff --git a/tests/run/closures_T82.pyx b/tests/run/closures_T82.pyx index 45f08785..2a53056e 100644 --- a/tests/run/closures_T82.pyx +++ b/tests/run/closures_T82.pyx @@ -73,13 +73,13 @@ def inner_override(a,b): def reassign(x): def f(a): return a+x - x = 1 # currently lacks a GIVEREF() + x = 1 return f def reassign_int(x): def f(int a): return a+x - x = 1 # currently lacks a GIVEREF() + x = 1 return f def reassign_int_int(int x): @@ -100,15 +100,15 @@ def cy_twofuncs(x): def more_inner_funcs(x): # pretty ugly segfault - def f(a): # this lacks a GIVEREF() + def f(a): def g(b): return a+b+x return g - def g(b): # this lacks a GIVEREF() + def g(b): def f(a): return a+b+x return f - def h(b): # this lacks a GIVEREF() + def h(b): def f(a): return a+b+x return f -- 2.26.2