Commit 45df4830 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2294 from newt0311/namespace_pkgs

Fix importing of namespace packages. Add in a regtest for the same.
parents beea3d2f 1f411b6f
......@@ -249,6 +249,10 @@ class PyxImporter(object):
def find_module(self, fullname, package_path=None):
if fullname in sys.modules and not pyxargs.reload_support:
return None # only here when reload()
# package_path might be a _NamespacePath. Convert that into a list...
if package_path is not None and not isinstance(package_path, list):
package_path = list(package_path)
try:
fp, pathname, (ext,mode,ty) = imp.find_module(fullname,package_path)
if fp: fp.close() # Python should offer a Default-Loader to avoid this double find/open!
......
......@@ -375,6 +375,7 @@ VER_DEP_MODULES = {
]),
(3,3) : (operator.lt, lambda x: x in ['build.package_compilation',
'run.yield_from_py33',
'pyximport.pyximport_namespace',
]),
(3,4): (operator.lt, lambda x: x in ['run.py34_signature',
]),
......
PYTHON -c "import basic_test; basic_test.test()"
######## basic_test.py ########
import os.path
import pyximport
pyximport.install(build_dir=os.path.join(os.path.dirname(__file__), "TEST_TMP"))
def test():
import nsmod.mymodule
assert nsmod.mymodule.test_string == "TEST"
assert not nsmod.mymodule.__file__.rstrip('oc').endswith('.py'), nsmod.mymodule.__file__
######## nsmod/mymodule.pyx ########
test_string = "TEST"
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