avoid reference count cycle in tuple extraction (#3976)

This commit is contained in:
David Hewitt 2024-03-22 22:43:05 +00:00 committed by GitHub
parent 990886efda
commit 20e477a7cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -690,10 +690,10 @@ fn type_output() -> TypeInfo {
let t = obj.downcast::<PyTuple>()?;
if t.len() == $length {
#[cfg(any(Py_LIMITED_API, PyPy))]
return Ok(($(t.get_item($n)?.extract::<$T>()?,)+));
return Ok(($(t.get_borrowed_item($n)?.extract::<$T>()?,)+));
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
unsafe {return Ok(($(t.get_item_unchecked($n).extract::<$T>()?,)+));}
unsafe {return Ok(($(t.get_borrowed_item_unchecked($n).extract::<$T>()?,)+));}
} else {
Err(wrong_tuple_length(t, $length))
}