Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
9ebceb76
Commit
9ebceb76
authored
May 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix path_hooks issue
Don't pass path to this version of find_module (unlike finders in meta_path).
parent
1216112d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
5 deletions
+31
-5
src/runtime/import.cpp
src/runtime/import.cpp
+3
-4
test/tests/sys_meta_path.py
test/tests/sys_meta_path.py
+28
-1
No files found.
src/runtime/import.cpp
View file @
9ebceb76
...
...
@@ -231,10 +231,9 @@ SearchResult findModule(const std::string& name, const std::string& full_name, B
return
SearchResult
(
""
,
SearchResult
::
SEARCH_ERROR
);
if
(
importer
!=
None
)
{
auto
path_pass
=
path_list
?
path_list
:
None
;
Box
*
loader
=
callattr
(
importer
,
&
find_module_str
,
CallattrFlags
({.
cls_only
=
false
,
.
null_on_nonexistent
=
false
}),
ArgPassSpec
(
2
),
boxString
(
full_name
),
path_pass
,
NULL
,
NULL
,
NULL
);
CallattrFlags
({.
cls_only
=
false
,
.
null_on_nonexistent
=
false
}),
ArgPassSpec
(
1
),
boxString
(
full_name
),
NULL
,
NULL
,
NULL
,
NULL
);
if
(
loader
!=
None
)
return
SearchResult
(
loader
);
}
...
...
@@ -489,7 +488,7 @@ Box* importModuleLevel(const std::string& name, Box* globals, Box* from_imports,
std
::
string
_name
=
name
;
Box
*
head
;
bool
again
=
loadNext
(
parent
,
level
<
0
?
N
ULL
:
parent
,
_name
,
buf
,
&
head
);
bool
again
=
loadNext
(
parent
,
level
<
0
?
N
one
:
parent
,
_name
,
buf
,
&
head
);
if
(
head
==
NULL
)
return
NULL
;
...
...
test/tests/sys_meta_path.py
View file @
9ebceb76
...
...
@@ -20,13 +20,40 @@ class Finder(object):
print
"find"
,
fullname
,
path
return
Loader
()
class
Finder2
(
object
):
def
__new__
(
cls
,
path
):
print
"new2"
,
path
return
object
.
__new__
(
cls
)
def
__init__
(
self
,
path
):
self
.
path
=
path
def
find_module
(
self
,
fullname
):
print
"find2"
,
self
.
path
,
fullname
return
None
# Fill the importer cache, so that we don't have to worry about the exact
# sys.path:
try
:
import
a.b.test
except
ImportError
,
e
:
print
"caught import error"
# The error CPython gives here is "No module named a.b.test". Both we and PyPy think this
# is wrong and that the error should be "No module named a".
# So unfortunately we can't print out the error message.
print
"caught import error 1"
sys
.
path_hooks
.
append
(
Finder2
)
try
:
import
a.b.test
except
ImportError
,
e
:
print
"caught import error 2"
sys
.
path
.
append
(
"/my_magic_directory"
)
try
:
import
a.b.test
except
ImportError
,
e
:
print
"caught import error 3"
sys
.
meta_path
.
append
(
Finder
())
import
a
...
...
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