Don't ignore exceptions caused by property getters and setters.

The exception is ignored only if the call was a meta call.
This commit is contained in:
Hugo Parente Lima 2010-09-15 10:40:52 -03:00
commit cd7dac40f7
3 changed files with 10 additions and 5 deletions

View file

@ -188,11 +188,7 @@ PyObject* qproperty_get(PyObject* self, PyObject* source)
Shiboken::AutoDecRef args(PyTuple_New(1)); Shiboken::AutoDecRef args(PyTuple_New(1));
Py_INCREF(source); Py_INCREF(source);
PyTuple_SET_ITEM(args, 0, source); PyTuple_SET_ITEM(args, 0, source);
PyObject *ret = PyObject_CallObject(data->fget, args); return PyObject_CallObject(data->fget, args);
if (!ret) {
PyErr_Print();
}
return ret;
} }
return 0; return 0;
} }

View file

@ -377,6 +377,8 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id,
args[0] = data; args[0] = data;
Py_DECREF(value); Py_DECREF(value);
} else if (PyErr_Occurred()) {
PyErr_Print(); // Clear any errors but print them to stderr
} }
break; break;
} }

View file

@ -129,6 +129,13 @@ class PropertyWithConstructorCase(unittest.TestCase):
obj = ExQObject(registeredproperty=123) obj = ExQObject(registeredproperty=123)
self.assertEqual(obj.registeredproperty, 123) self.assertEqual(obj.registeredproperty, 123)
def testPythonDeclaredPropertyNoSetted(self):
try:
obj = ExQObject()
a = obj.registeredproperty
except AttributeError:
pass
def testConstructorPropertyInQObjectDerived(self): def testConstructorPropertyInQObjectDerived(self):
#QTimer(property=value) for existing C++ property #QTimer(property=value) for existing C++ property
obj = QTimer(objectName='dummy') obj = QTimer(objectName='dummy')