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
f78cf569
Commit
f78cf569
authored
Mar 24, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a few missing imp functions
parent
415673dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
src/runtime/import.cpp
src/runtime/import.cpp
+27
-0
test/tests/imp_test.py
test/tests/imp_test.py
+3
-0
No files found.
src/runtime/import.cpp
View file @
f78cf569
...
...
@@ -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"
));
}
}
test/tests/imp_test.py
View file @
f78cf569
...
...
@@ -13,3 +13,6 @@ for a in (1, "", "/proc", "nonexisting_dir"):
except
Exception
as
e
:
print
e
imp
.
acquire_lock
()
imp
.
release_lock
()
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