Skip to content

Commit 6991a80

Browse files
committed
Add __main__.__cached__
1 parent 4f8ef16 commit 6991a80

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

crates/vm/src/vm/compile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ impl VirtualMachine {
6969
self.ctx.new_str(path).into(),
7070
self,
7171
)?;
72+
module_dict.set_item(identifier!(self, __cached__), self.ctx.none(), self)?;
7273
}
7374

7475
// Consider to use enum to distinguish `path`

crates/vm/src/vm/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ declare_const_name! {
9898
__build_class__,
9999
__builtins__,
100100
__bytes__,
101+
__cached__,
101102
__call__,
102103
__ceil__,
103104
__cformat__,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import sys
2+
3+
main_module = sys.modules["__main__"]
4+
assert main_module.__file__.endswith("builtin___main__.py")
5+
assert main_module.__cached__ is None

0 commit comments

Comments
 (0)