Commit f5d262cc authored by Kevin Modzelewski's avatar Kevin Modzelewski

Make find_module support packages

parent 14dd8e7d
......@@ -48,6 +48,7 @@
#define HAVE_POLL 1
#define HAVE_SELECT 1
#define HAVE_ALARM 1
#define HAVE_SYMLINK 1
#define PY_FORMAT_LONG_LONG "ll"
#define PY_FORMAT_SIZE_T "z"
......
......@@ -269,8 +269,13 @@ Box* impFindModule(Box* _name) {
Box* path = boxString(sr.path);
Box* mode = boxStrConstant("r");
Box* f = runtimeCall(file_cls, ArgPassSpec(2), path, mode, NULL, NULL, NULL);
return new BoxedTuple(
{ f, path, new BoxedTuple({ boxStrConstant(".py"), mode, boxInt(SearchResult::PY_SOURCE) }) });
return new BoxedTuple({ f, path, new BoxedTuple({ boxStrConstant(".py"), mode, boxInt(sr.type) }) });
}
if (sr.type == SearchResult::PKG_DIRECTORY) {
Box* path = boxString(sr.path);
Box* mode = boxStrConstant("");
return new BoxedTuple({ None, path, new BoxedTuple({ mode, mode, boxInt(sr.type) }) });
}
Py_FatalError("unimplemented");
......
import imp
print len(imp.find_module("os"))
print imp.find_module("encodings")[0]
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