From 20e477a7cd19c5bfeec1ebe813d2df2cea0f8a2b Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Fri, 22 Mar 2024 22:43:05 +0000 Subject: [PATCH] avoid reference count cycle in tuple extraction (#3976) --- src/types/tuple.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/tuple.rs b/src/types/tuple.rs index d8053e1441a..d89830daa97 100644 --- a/src/types/tuple.rs +++ b/src/types/tuple.rs @@ -690,10 +690,10 @@ fn type_output() -> TypeInfo { let t = obj.downcast::()?; 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)) }