Skip to content

Commit 8f036b3

Browse files
committed
quickfix Lib/test list test_extend
1 parent bb45696 commit 8f036b3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

vm/src/obj/objiter.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ pub fn get_next_object(
6565
/* Retrieve all elements from an iterator */
6666
pub fn get_all<T: TryFromObject>(vm: &VirtualMachine, iter_obj: &PyObjectRef) -> PyResult<Vec<T>> {
6767
let cap = length_hint(vm, iter_obj.clone())?.unwrap_or(0);
68+
// TODO: fix extend to do this check (?), see test_extend in Lib/test/list_tests.py,
69+
// https://github.com/python/cpython/blob/master/Objects/listobject.c#L934-L940
70+
if cap >= isize::max_value() as usize {
71+
return Ok(Vec::new());
72+
}
6873
let mut elements = Vec::with_capacity(cap);
6974
while let Some(element) = get_next_object(vm, iter_obj)? {
7075
elements.push(T::try_from_object(vm, element)?);

0 commit comments

Comments
 (0)