From: Gregory Ewing Date: Mon, 26 Nov 2007 09:49:11 +0000 (+1300) Subject: Keep counted reference to module X-Git-Tag: 0.9.8rc1~32^2~3^2~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4572c0b048f667d9bb6ab6ba1e5050ef43377717;p=cython.git 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] --- 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)