Commit a76ed42c by Dean Moldovan Committed by Wenzel Jakob

Fix sequence_item reference leak (#660)

parent 5e92b3e6
......@@ -254,7 +254,7 @@ public:
.. code-block:: cpp
PyObject *result = PySequence_GetItem(obj, index);
PyObject *p = PyList_GetItem(obj, index);
py::object o = reinterpret_borrow<py::object>(p);
// or
py::tuple t = reinterpret_borrow<py::tuple>(p); // <-- `p` must be already be a `tuple`
......@@ -453,7 +453,7 @@ struct sequence_item {
static object get(handle obj, size_t index) {
PyObject *result = PySequence_GetItem(obj.ptr(), static_cast<ssize_t>(index));
if (!result) { throw error_already_set(); }
return reinterpret_borrow<object>(result);
return reinterpret_steal<object>(result);
}
static void set(handle obj, size_t index, handle val) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment