More refnanny fixes
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Thu, 29 Jan 2009 19:51:23 +0000 (20:51 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Thu, 29 Jan 2009 19:51:23 +0000 (20:51 +0100)
Cython/Compiler/ExprNodes.py
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py

index e183a013bd11df5c7c2702b377eff7fb7ceae915..f55c715cd8570a59d84c04b2dcaadba95ad51f75 100644 (file)
@@ -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:")
index ec5c473c0edfc54909c21356214eb9ecd22cfa31..1982775024658b922aff7719f2e53ba6b533cbdc 100644 (file)
@@ -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")
index 8b5c95b54ef4c19aa0d466b97b8997f96eba33ea..46c11dca03e6e9073f81f9663bdf9a520531e69b 100644 (file)
@@ -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)