diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-03-23 19:14:42 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:05 -0300 |
commit | 61f479b6826f7d88c02c0ab5986e8e2c08be5518 (patch) | |
tree | 9b0b83f643e49bfb6587e1348477fc6557c4dd49 | |
parent | e360a53087975cac53975f00e747991b7eb818af (diff) |
Fix bug 699 - "PySide.QtCore.Property doesn't throw a TypeError if the first arg isn't a PyType."
-rw-r--r-- | libpyside/pysideproperty.cpp | 14 | ||||
-rw-r--r-- | tests/QtCore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtCore/bug_699.py | 17 |
3 files changed, 25 insertions, 7 deletions
diff --git a/libpyside/pysideproperty.cpp b/libpyside/pysideproperty.cpp index 839e55f35..4e9b724ea 100644 --- a/libpyside/pysideproperty.cpp +++ b/libpyside/pysideproperty.cpp @@ -168,14 +168,14 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds) return 0; } - if (pData->constant && (pData->fset || pData->notify)) { - free(pData); - PyErr_SetString(PyExc_AttributeError, "A constant property cannot have a WRITE method or a NOTIFY signal."); - return 0; - - } pData->typeName = PySide::Signal::getTypeName(type); - return 1; + + if (!pData->typeName) + PyErr_SetString(PyExc_TypeError, "Invalid property type or type name."); + else if (pData->constant && (pData->fset || pData->notify)) + PyErr_SetString(PyExc_TypeError, "A constant property cannot have a WRITE method or a NOTIFY signal."); + + return PyErr_Occurred() ? -1 : 1; } void qpropertyFree(void *self) diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 434c8fe83..48de2c4bb 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -6,6 +6,7 @@ PYSIDE_TEST(bug_462.py) PYSIDE_TEST(bug_505.py) PYSIDE_TEST(bug_515.py) PYSIDE_TEST(bug_656.py) +PYSIDE_TEST(bug_699.py) PYSIDE_TEST(bug_706.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(child_event_test.py) diff --git a/tests/QtCore/bug_699.py b/tests/QtCore/bug_699.py new file mode 100644 index 000000000..e731b5be2 --- /dev/null +++ b/tests/QtCore/bug_699.py @@ -0,0 +1,17 @@ +import unittest +from PySide.QtCore import * + +class TestBug699 (unittest.TestCase): + + def defClass(self): + class Foo (QObject): + def foo(self): + pass + + prop = Property(foo, foo) + + def testIt(self): + self.assertRaises(TypeError, self.defClass) + +if __name__ == '__main__': + unittest.main() |