mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
quickfix Lib/test list test_extend
This commit is contained in:
@@ -65,6 +65,11 @@ pub fn get_next_object(
|
||||
/* Retrieve all elements from an iterator */
|
||||
pub fn get_all<T: TryFromObject>(vm: &VirtualMachine, iter_obj: &PyObjectRef) -> PyResult<Vec<T>> {
|
||||
let cap = length_hint(vm, iter_obj.clone())?.unwrap_or(0);
|
||||
// TODO: fix extend to do this check (?), see test_extend in Lib/test/list_tests.py,
|
||||
// https://github.com/python/cpython/blob/master/Objects/listobject.c#L934-L940
|
||||
if cap >= isize::max_value() as usize {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
let mut elements = Vec::with_capacity(cap);
|
||||
while let Some(element) = get_next_object(vm, iter_obj)? {
|
||||
elements.push(T::try_from_object(vm, element)?);
|
||||
|
||||
Reference in New Issue
Block a user