We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bb45696 commit 8f036b3Copy full SHA for 8f036b3
vm/src/obj/objiter.rs
@@ -65,6 +65,11 @@ pub fn get_next_object(
65
/* Retrieve all elements from an iterator */
66
pub fn get_all<T: TryFromObject>(vm: &VirtualMachine, iter_obj: &PyObjectRef) -> PyResult<Vec<T>> {
67
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
+ }
73
let mut elements = Vec::with_capacity(cap);
74
while let Some(element) = get_next_object(vm, iter_obj)? {
75
elements.push(T::try_from_object(vm, element)?);
0 commit comments