From 4572c0b048f667d9bb6ab6ba1e5050ef43377717 Mon Sep 17 00:00:00 2001 From: Gregory Ewing Date: Mon, 26 Nov 2007 22:49:11 +1300 Subject: [PATCH] Keep counted reference to module + + - A counted reference was not kept to the module, so if the entry + in sys.modules was replaced, the module was freed prematurely. + [Franck Pommerau] --- Cython/Compiler/ModuleNode.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 99065b61..c86204fb 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1543,6 +1543,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): "if (!%s) %s;" % ( env.module_cname, code.error_goto(self.pos))); + code.putln( + "Py_INCREF(%s);" % + env.module_cname) code.putln( '%s = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME);' % Naming.builtins_cname) -- 2.26.2