Commit 5fb2c885 authored by Stefan Behnel's avatar Stefan Behnel

fix early module registering by using FQMN instead of plain module name, added...

fix early module registering by using FQMN instead of plain module name, added test for init-time reloading of modules in packages
parent cf20c0d9
......@@ -2095,9 +2095,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("{")
code.putln("PyObject *modules = PyImport_GetModuleDict(); %s" %
code.error_goto_if_null("modules", self.pos))
code.putln('if (!PyDict_GetItemString(modules, "%s")) {' % env.module_name)
code.putln('if (!PyDict_GetItemString(modules, "%s")) {' % env.qualified_name)
code.putln(code.error_goto_if_neg('PyDict_SetItemString(modules, "%s", %s)' % (
env.module_name, env.module_cname), self.pos))
env.qualified_name, env.module_cname), self.pos))
code.putln("}")
code.putln("}")
code.putln("#endif")
......
PYTHON setup.py build_ext --inplace
PYTHON -c "import a"
######## setup.py ########
from Cython.Build.Dependencies import cythonize
import Cython.Compiler.Options
Cython.Compiler.Options.cimport_from_pyx = True
from distutils.core import setup
setup(
ext_modules = cythonize("**/*.pyx"),
)
######## a.pyx ########
import sys
import a
assert a in sys.modules.values(), list(sys.modules)
assert sys.modules['a'] is a, list(sys.modules)
from atest.package import module
######## atest/__init__.py ########
######## atest/package/__init__.py ########
######## atest/package/module.pyx ########
import sys
assert 'atest.package.module' in sys.modules
import a
import atest.package.module as module
assert module in sys.modules.values(), list(sys.modules)
assert sys.modules['atest.package.module'] is module, list(sys.modules)
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