summaryrefslogtreecommitdiffstats
path: root/libshiboken/conversions.h
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-03-17 14:09:23 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-03-18 19:45:07 -0300
commitca2febda4080bb7ea2bd94aa9c8bf3ce18dccac0 (patch)
tree331f95ac6fee830788367d1675efc80ba140ab78 /libshiboken/conversions.h
parentb6e8e35cdcf9946ad6672df340b55fa8843b72b9 (diff)
downloadshiboken-ca2febda4080bb7ea2bd94aa9c8bf3ce18dccac0.tar.gz
shiboken-ca2febda4080bb7ea2bd94aa9c8bf3ce18dccac0.tar.xz
shiboken-ca2febda4080bb7ea2bd94aa9c8bf3ce18dccac0.zip
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.
Diffstat (limited to 'libshiboken/conversions.h')
-rw-r--r--libshiboken/conversions.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index 2d09ac07..600280c9 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -508,7 +508,11 @@ struct StdListConverter
{
if (PyObject_TypeCheck(pyObj, SbkType<StdList>()))
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<StdList>() && 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<StdPair>()))
return true;
- if (!PySequence_Check(pyObj) || PySequence_Length(pyObj) != 2)
+ if ((SbkType<StdPair>() && 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<StdMap>()))
return true;
- if (!PyDict_Check(pyObj))
+ if ((SbkType<StdMap>() && isShibokenType(pyObj)) || !PyDict_Check(pyObj))
return false;
PyObject* key;