aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-04-05 18:10:23 -0300
committerHugo Parente Lima <hugo.lima@openbossa.org>2010-04-06 19:11:11 -0300
commita5b2237ee0a7a894e1eac4e2c0f4b270866a059a (patch)
tree22ced4e4a694f8ed9477fba2062e11806f3c2e7f
parent826678cb91124784339c2a92118e82413ef03b5c (diff)
None is convertible to QString, the result is a QString where QString.isNull is true.
-rw-r--r--PySide/QtCore/qstring_conversions.h3
-rw-r--r--tests/qtcore/qobject_test.py6
-rw-r--r--tests/qtcore/qstring_test.py4
3 files changed, 7 insertions, 6 deletions
diff --git a/PySide/QtCore/qstring_conversions.h b/PySide/QtCore/qstring_conversions.h
index d2edf9479..2c59928dd 100644
--- a/PySide/QtCore/qstring_conversions.h
+++ b/PySide/QtCore/qstring_conversions.h
@@ -7,6 +7,7 @@ inline bool Converter<QString>::isConvertible(PyObject* pyObj)
|| PyUnicode_Check(pyObj)
|| SbkQByteArray_Check(pyObj)
|| SbkQLatin1String_Check(pyObj)
+ || pyObj == Py_None
#if PY_VERSION_HEX < 0x03000000
|| (pyObj->ob_type->tp_as_buffer
&& PyType_HasFeature(pyObj->ob_type, Py_TPFLAGS_HAVE_GETCHARBUFFER)
@@ -35,6 +36,8 @@ inline QString Converter<QString>::toCpp(PyObject* pyObj)
#endif
} else if (PyString_Check(pyObj)) {
return QString(Converter< char * >::toCpp(pyObj));
+ } else if (pyObj == Py_None) {
+ return QString();
}
#if PY_VERSION_HEX < 0x03000000
// Support for buffer objects on QString constructor
diff --git a/tests/qtcore/qobject_test.py b/tests/qtcore/qobject_test.py
index 848cce361..a1749babc 100644
--- a/tests/qtcore/qobject_test.py
+++ b/tests/qtcore/qobject_test.py
@@ -25,12 +25,6 @@ class ObjectNameCase(unittest.TestCase):
self.assertEqual(name, obj.objectName())
- def testNone(self):
- #QObject.objectName(None)
- obj = QObject()
-
- self.assertRaises(TypeError, obj.setObjectName, None)
-
def testDefault(self):
#QObject.objectName() default
obj = QObject()
diff --git a/tests/qtcore/qstring_test.py b/tests/qtcore/qstring_test.py
index 193ef0910..9bb68a3ed 100644
--- a/tests/qtcore/qstring_test.py
+++ b/tests/qtcore/qstring_test.py
@@ -105,6 +105,10 @@ class QStringConstructor(unittest.TestCase):
self.assertEqual(obj1, obj2)
+ def testNullQString(self):
+ s = QString(None)
+ self.assertTrue(s.isNull())
+
def testQStringFromPy(self):
#QString(const char*)
sample = 'a new string'