From 92aaff74ee9781cb8ef8f77a11de577f729b2705 Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Thu, 29 Jan 2009 20:51:23 +0100 Subject: [PATCH] More refnanny fixes --- Cython/Compiler/ExprNodes.py | 4 ++++ Cython/Compiler/ModuleNode.py | 8 ++++++-- Cython/Compiler/Nodes.py | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index e183a013..f55c715c 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1333,6 +1333,8 @@ class NameNode(AtomicExprNode): #print "...from", rhs ### #print "...LHS type", self.type, "ctype", self.ctype() ### #print "...RHS type", rhs.type, "ctype", rhs.ctype() ### + if entry.is_cglobal: + code.put_gotref(self.py_result()) if not self.lhs_of_first_assignment: if entry.is_local and not Options.init_local_none: initalized = entry.scope.control_flow.get_state((entry.name, 'initalized'), self.pos) @@ -1342,6 +1344,8 @@ class NameNode(AtomicExprNode): code.put_xdecref(self.result(), self.ctype()) else: code.put_decref(self.result(), self.ctype()) + if entry.is_cglobal: + code.put_giveref(rhs.py_result()) code.putln('%s = %s;' % (self.result(), rhs.result_as(self.ctype()))) if debug_disposal_code: print("NameNode.generate_assignment_code:") diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index ec5c473c..19827750 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1640,8 +1640,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): env.use_utility_code(Nodes.traceback_utility_code) code.putln("%s = NULL;" % Naming.retval_cname) code.put_label(code.return_label) - code.put_finish_refcount_context(self.pos, env.qualified_name, - Naming.retval_cname, "NULL") + # Disabled because of confusion with refcount of global variables -- run ass2cglobal testcase to see + #code.put_finish_refcount_context(self.pos, env.qualified_name, + # Naming.retval_cname, "NULL") + code.putln("#if CYTHON_REFNANNY") + code.putln("if (__pyx_refchk) {};") + code.putln("#endif") code.putln("#if PY_MAJOR_VERSION < 3") code.putln("return;") code.putln("#else") diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 8b5c95b5..46c11dca 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -4170,6 +4170,8 @@ class ExceptClauseNode(Node): exc_args = "&%s, &%s, &%s" % tuple(self.exc_vars) code.putln("if (__Pyx_GetException(%s) < 0) %s" % (exc_args, code.error_goto(self.pos))) + for x in self.exc_vars: + code.put_gotref(x) if self.target: self.exc_value.generate_evaluation_code(code) self.target.generate_assignment_code(self.exc_value, code) -- 2.26.2