From ca2febda4080bb7ea2bd94aa9c8bf3ce18dccac0 Mon Sep 17 00:00:00 2001 From: Hugo Lima Date: Wed, 17 Mar 2010 14:09:23 -0300 Subject: Sequence conversion are made ONLY for python sequences. Not for binded types implementing sequence protocol, otherwise this will cause a mess like QBitArray being accepted by someone expecting a QStringList. --- libshiboken/conversions.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libshiboken') diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h index 2d09ac07f..600280c9f 100644 --- a/libshiboken/conversions.h +++ b/libshiboken/conversions.h @@ -508,7 +508,11 @@ struct StdListConverter { if (PyObject_TypeCheck(pyObj, SbkType())) return true; - if (!PySequence_Check(pyObj)) + // Sequence conversion are made ONLY for python sequences, not for + // binded types implementing sequence protocol, otherwise this will + // cause a mess like QBitArray being accepted by someone expecting a + // QStringList. + if ((SbkType() && isShibokenType(pyObj)) || !PySequence_Check(pyObj)) return false; for (int i = 0, max = PySequence_Length(pyObj); i < max; ++i) { AutoDecRef item(PySequence_GetItem(pyObj, i)); @@ -545,7 +549,7 @@ struct StdPairConverter { if (PyObject_TypeCheck(pyObj, SbkType())) return true; - if (!PySequence_Check(pyObj) || PySequence_Length(pyObj) != 2) + if ((SbkType() && isShibokenType(pyObj)) || !PySequence_Check(pyObj) || PySequence_Length(pyObj) != 2) return false; AutoDecRef item1(PySequence_GetItem(pyObj, 0)); @@ -584,7 +588,7 @@ struct StdMapConverter { if (PyObject_TypeCheck(pyObj, SbkType())) return true; - if (!PyDict_Check(pyObj)) + if ((SbkType() && isShibokenType(pyObj)) || !PyDict_Check(pyObj)) return false; PyObject* key; -- cgit v1.2.3