Skip to content

Commit 284ba4f

Browse files
committed
Don't set __file__ for frozen modules
1 parent d0ea3ba commit 284ba4f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

vm/src/import.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ pub fn import_file(
8080

8181
let attrs = vm.ctx.new_dict();
8282
attrs.set_item("__name__", vm.new_str(module_name.to_string()), vm)?;
83-
attrs.set_item("__file__", vm.new_str(file_path), vm)?;
83+
if file_path != "frozen".to_string() {
84+
// TODO: Should be removed after precompiling frozen modules.
85+
attrs.set_item("__file__", vm.new_str(file_path), vm)?;
86+
}
8487
let module = vm.ctx.new_module(module_name, attrs.clone());
8588

8689
// Store module in cache to prevent infinite loop with mutual importing libs:

0 commit comments

Comments
 (0)