diff options
-rw-r--r-- | sources/shiboken2/libshiboken/basewrapper.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index b46fbaef2..ae6b2a68a 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -828,7 +828,14 @@ Py_hash_t hash(PyObject* pyObj) static void setSequenceOwnership(PyObject* pyObj, bool owner) { - if (PySequence_Check(pyObj)) { + + bool has_length = true; + if (PySequence_Size(pyObj) < 0) { + PyErr_Clear(); + has_length = false; + } + + if (PySequence_Check(pyObj) && has_length) { Py_ssize_t size = PySequence_Size(pyObj); if (size > 0) { std::list<SbkObject*> objs = splitPyObject(pyObj); |