Fix function import refcount (Stefan Behnel)
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 1 Nov 2007 01:58:28 +0000 (18:58 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 1 Nov 2007 01:58:28 +0000 (18:58 -0700)
Cython/Compiler/ModuleNode.py

index 84f5af045dfdd15737969bf72874c957c4fd4fdd..8526687be25cda941a0e537950ac65052af686e7 100644 (file)
@@ -166,9 +166,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
                         entry.name,
                         entry.cname,
                         sig))
-            h_code.putln("Py_DECREF(module);")
+            h_code.putln("Py_DECREF(module); module = 0;")
             for entry in public_extension_types:
-                self.generate_type_import_call(entry.type, h_code, "goto bad;")
+                self.generate_type_import_call(
+                    entry.type, h_code,
+                    "if (!%s) goto bad;" % entry.type.typeptr_cname)
             h_code.putln("return 0;")
             h_code.putln("bad:")
             h_code.putln("Py_XDECREF(module);")