From 1579307e649dd1ee74c020c6a47d49ac563a4e96 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sun, 3 May 2020 13:39:19 +0100 Subject: [PATCH] Allow borrowed object for PyTuple::get_item. As per feedback on #890 --- src/types/tuple.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/types/tuple.rs b/src/types/tuple.rs index cc8be95ef18..e78b34afdbd 100644 --- a/src/types/tuple.rs +++ b/src/types/tuple.rs @@ -72,10 +72,7 @@ impl PyTuple { pub fn get_item(&self, index: usize) -> &PyAny { assert!(index < self.len()); unsafe { - // PyTuple_GET_ITEM return borrowed ptr; must make owned for safety (see #890). - let ptr = ffi::PyTuple_GET_ITEM(self.as_ptr(), index as Py_ssize_t); - ffi::Py_INCREF(ptr); - self.py().from_owned_ptr(ptr) + self.py().from_owned_ptr(ffi::PyTuple_GET_ITEM(self.as_ptr(), index as Py_ssize_t)) } }