Commit d59c39ac authored by Stefan Behnel's avatar Stefan Behnel

always insert the module into sys.modules right after creating it in Py3 (Py2 does it for us)

--HG--
extra : transplant_source : %F9%FF%8Ai%99OV%BFd%F7%147%19pm%5D%DF%98%D4%FC
parent 9df8c9da
......@@ -2090,8 +2090,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
Naming.pymoduledef_cname))
code.putln("#endif")
code.putln(code.error_goto_if_null(env.module_cname, self.pos))
if env.is_package:
# CPython may not have put us into sys.modules yet, but relative imports require it
# CPython may not have put us into sys.modules yet, but relative imports and reimports require it
code.putln("#if PY_MAJOR_VERSION >= 3")
code.putln("{")
code.putln("PyObject *modules = PyImport_GetModuleDict(); %s" %
code.error_goto_if_null("modules", self.pos))
......@@ -2100,6 +2100,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
env.module_name, env.module_cname), self.pos))
code.putln("}")
code.putln("}")
code.putln("#endif")
code.putln(
'%s = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); %s' % (
Naming.builtins_cname,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment