Skip to content

Commit

Permalink
Allow borrowed object for PyTuple::get_item.
Browse files Browse the repository at this point in the history
As per feedback on #890
  • Loading branch information
davidhewitt committed May 3, 2020
1 parent b7ecec7 commit 1579307
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/types/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 1579307

Please sign in to comment.