Skip to content

Commit 6404c4b

Browse files
authored
Merge pull request #4555 from youknowone/imp-override-frozen-modules
Add _imp._override_frozen_modules_for_tests
2 parents 5018b1a + 5e3046d commit 6404c4b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

vm/src/stdlib/imp.rs

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ mod _imp {
116116
.ok_or_else(|| vm.new_import_error(format!("No such frozen object named {name}"), name))
117117
}
118118

119+
#[pyfunction]
120+
fn _override_frozen_modules_for_tests(value: isize, vm: &VirtualMachine) {
121+
vm.state.override_frozen_modules.store(value);
122+
}
123+
119124
#[pyfunction]
120125
fn _fix_co_filename(_code: PyObjectRef, _path: PyStrRef) {
121126
// TODO:

vm/src/vm/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ pub struct PyGlobalState {
9696
pub codec_registry: CodecsRegistry,
9797
pub finalizing: AtomicBool,
9898
pub warnings: WarningsState,
99+
pub override_frozen_modules: AtomicCell<isize>,
99100
}
100101

101102
pub fn process_hash_secret_seed() -> u32 {
@@ -172,6 +173,7 @@ impl VirtualMachine {
172173
codec_registry,
173174
finalizing: AtomicBool::new(false),
174175
warnings,
176+
override_frozen_modules: AtomicCell::new(0),
175177
}),
176178
initialized: false,
177179
recursion_depth: Cell::new(0),

0 commit comments

Comments
 (0)