Commit c8640d65 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)

parent 2ead392c
...@@ -2088,8 +2088,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2088,8 +2088,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
Naming.pymoduledef_cname)) Naming.pymoduledef_cname))
code.putln("#endif") code.putln("#endif")
code.putln(code.error_goto_if_null(env.module_cname, self.pos)) 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 and reimports require it
# CPython may not have put us into sys.modules yet, but relative imports require it code.putln("#if PY_MAJOR_VERSION >= 3")
code.putln("{") code.putln("{")
code.putln("PyObject *modules = PyImport_GetModuleDict(); %s" % code.putln("PyObject *modules = PyImport_GetModuleDict(); %s" %
code.error_goto_if_null("modules", self.pos)) code.error_goto_if_null("modules", self.pos))
...@@ -2098,6 +2098,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2098,6 +2098,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
env.module_name, env.module_cname), self.pos)) env.module_name, env.module_cname), self.pos))
code.putln("}") code.putln("}")
code.putln("}") code.putln("}")
code.putln("#endif")
code.putln( code.putln(
'%s = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); %s' % ( '%s = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); %s' % (
Naming.builtins_cname, 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