🌐 AI搜索 & 代理 主页
Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[squash] Test of changed size in the lookup mehtod
  • Loading branch information
kralka committed Oct 28, 2025
commit 71066cee1c60fc3e06f9a99937ad910abf79a217
11 changes: 10 additions & 1 deletion vm/src/dict_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ impl<T: Clone> Dict<T> {
) -> PyResult<LookupResult> {
let mut idxs = None;
let mut free_slot = None;
let original_size = self.size();
let ret = 'outer: loop {
let (entry_key, ret) = {
let inner = lock.take().unwrap_or_else(|| self.read());
Expand All @@ -585,7 +586,7 @@ impl<T: Clone> Dict<T> {
let index_entry = match inner.indices.get(index_index) {
None => {
// Dictionary was modified under our hands, see TestMethodsMutating.
continue 'outer;
return Err(vm.new_runtime_error("set changed size during iteration"));
}
Some(v) => *v,
};
Expand All @@ -600,6 +601,11 @@ impl<T: Clone> Dict<T> {
Some(free) => (IndexEntry::DUMMY, free),
None => (IndexEntry::FREE, index_index),
};
if self.has_changed_size(&original_size) {
return Err(
vm.new_runtime_error("set changed size during iteration")
);
}
return Ok(idxs);
}
idx => {
Expand Down Expand Up @@ -631,6 +637,9 @@ impl<T: Clone> Dict<T> {

// warn!("Perturb value: {}", i);
};
if self.has_changed_size(&original_size) {
return Err(vm.new_runtime_error("set changed size during iteration"));
}
Ok(ret)
}

Expand Down
Loading