Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
65fb9d79
Commit
65fb9d79
authored
May 24, 2018
by
Prakhar Goel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix importing of namespace packages. Add in a regtest for the same.
parent
8cab7b0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
pyximport/pyximport.py
pyximport/pyximport.py
+4
-0
tests/pyximport/pyximport_namespace.srctree
tests/pyximport/pyximport_namespace.srctree
+18
-0
No files found.
pyximport/pyximport.py
View file @
65fb9d79
...
...
@@ -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!
...
...
tests/pyximport/pyximport_namespace.srctree
0 → 100644
View file @
65fb9d79
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"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment