Commit f78cf569 authored by Marius Wachtler's avatar Marius Wachtler

Add a few missing imp functions

parent 415673dc
......@@ -684,6 +684,26 @@ Box* impLoadModule(Box* _name, Box* _file, Box* _pathname, Box** args) {
Py_FatalError("unimplemented");
}
Box* impGetSuffixes() {
BoxedList* list = new BoxedList;
// For now only add *.py
listAppendInternal(
list, new BoxedTuple({ new BoxedString(".py"), new BoxedString("U"), boxInt(SearchResult::PY_SOURCE) }));
return list;
}
Box* impAcquireLock() {
_PyImport_AcquireLock();
checkAndThrowCAPIException();
return None;
}
Box* impReleaseLock() {
_PyImport_ReleaseLock();
checkAndThrowCAPIException();
return None;
}
void setupImport() {
BoxedModule* imp_module
= createModule("imp", "__builtin__", "'This module provides the components needed to build your own\n"
......@@ -714,5 +734,12 @@ void setupImport() {
ParamNames({ "name", "file", "pathname", "description" }, "", ""));
imp_module->giveAttr("load_module", new BoxedBuiltinFunctionOrMethod(load_module_func, "load_module"));
imp_module->giveAttr("get_suffixes", new BoxedBuiltinFunctionOrMethod(
boxRTFunction((void*)impGetSuffixes, UNKNOWN, 0), "get_suffixes"));
imp_module->giveAttr("acquire_lock", new BoxedBuiltinFunctionOrMethod(boxRTFunction((void*)impAcquireLock, NONE, 0),
"acquire_lock"));
imp_module->giveAttr("release_lock", new BoxedBuiltinFunctionOrMethod(boxRTFunction((void*)impReleaseLock, NONE, 0),
"release_lock"));
}
}
......@@ -13,3 +13,6 @@ for a in (1, "", "/proc", "nonexisting_dir"):
except Exception as e:
print e
imp.acquire_lock()
imp.release_lock()
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