forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimp.py
More file actions
28 lines (19 loc) · 634 Bytes
/
imp.py
File metadata and controls
28 lines (19 loc) · 634 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import _imp
import time as import_time
assert _imp.is_builtin("time") == True
assert _imp.is_builtin("os") == False
assert _imp.is_builtin("not existing module") == False
assert _imp.is_frozen("__hello__") == True
assert _imp.is_frozen("os") == False
class FakeSpec:
def __init__(self, name):
self.name = name
A = FakeSpec("time")
imp_time = _imp.create_builtin(A)
assert imp_time.sleep == import_time.sleep
B = FakeSpec("not existing module")
assert _imp.create_builtin(B) == None
_imp.exec_builtin(imp_time) == 0
_imp.get_frozen_object("__hello__")
hello = _imp.init_frozen("__hello__")
assert hello.initialized == True