diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index ae0ad780..e44f8ac5 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -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(p); // or py::tuple t = reinterpret_borrow(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(index)); if (!result) { throw error_already_set(); } - return reinterpret_borrow(result); + return reinterpret_steal(result); } static void set(handle obj, size_t index, handle val) {