According to https://docs.python.org/2.7/c-api/unicode.html#c.PyUnicode_Decode , PyUnicode_Decode returns New reference. Meanwhile, pybind11::object internally increases the reference count when constructed. It seems like the latter causes double-increasing. To disable auto-increasing reference count, we should use py::reinterpret_steal.
This can also be said to handle_to_object, whose user is PyInt_FromLong.
According to https://docs.python.org/2.7/c-api/unicode.html#c.PyUnicode_Decode , PyUnicode_Decode returns New reference. Meanwhile, pybind11::object internally increases the reference count when constructed. It seems like the latter causes double-increasing. To disable auto-increasing reference count, we should use py::reinterpret_steal.
This can also be said to handle_to_object, whose user is PyInt_FromLong.