diff options
author | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2023-08-03 17:33:41 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-02-25 22:24:29 +0000 |
commit | d8438d0a3922934fc17671eb45dd7b7377fe37e1 (patch) | |
tree | 1174ce38005264ea4a936a19566507fcca047216 | |
parent | 354d601dedb58b4e28f1bbdde9dc0e12ede3afd3 (diff) |
signature: Add support for classmethods
Two tests were adapted, because now the missing signature
error message:
TypeError: xxx.__dict__['yyy'].fset(<class 'object'>) is wrong (missing signature)
does not apply, and we get the usual message:
TypeError: xxx.__dict__['yyy'].fset" called with wrong argument types:
this comes from the fact that we are not getting the string
representation of the signature, but the data type itself.
Change-Id: Ib9c8b7f863063b384c41dea32e2b4b01f0695f82
Fixes: PYSIDE-1955
Pick-to: 6.5 6.2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 94869cf1cacb1a5c2d722f49feb8e8af895144bc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/pyside6/tests/QtCore/errormessages_with_features_test.py | 9 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/signature/signature.cpp | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/sources/pyside6/tests/QtCore/errormessages_with_features_test.py b/sources/pyside6/tests/QtCore/errormessages_with_features_test.py index 8cb38882a..97c4f942e 100644 --- a/sources/pyside6/tests/QtCore/errormessages_with_features_test.py +++ b/sources/pyside6/tests/QtCore/errormessages_with_features_test.py @@ -34,7 +34,6 @@ This test is in its own file because combining it with @unittest.skipIf(is_pypy, "__feature__ cannot yet be used with PyPy") class ErrormessagesWithFeatures(unittest.TestCase): probe = "called with wrong argument types" - probe_miss = "missing signature" def setUp(self): qApp or QApplication() @@ -76,20 +75,20 @@ class ErrormessagesWithFeatures(unittest.TestCase): with self.assertRaises(TypeError) as cm: QApplication.quitOnLastWindowClosed = object print("\n\n" + cm.exception.args[0]) - self.assertTrue(self.probe_miss in cm.exception.args[0]) + self.assertTrue(self.probe in cm.exception.args[0]) with self.assertRaises(TypeError) as cm: qApp.quitOnLastWindowClosed = object - self.assertTrue(self.probe_miss in cm.exception.args[0]) + self.assertTrue(self.probe in cm.exception.args[0]) def testCorrectErrorMessagesClassSnakeProp(self): from __feature__ import snake_case, true_property with self.assertRaises(TypeError) as cm: QApplication.quit_on_last_window_closed = object print("\n\n" + cm.exception.args[0]) - self.assertTrue(self.probe_miss in cm.exception.args[0]) + self.assertTrue(self.probe in cm.exception.args[0]) with self.assertRaises(TypeError) as cm: qApp.quit_on_last_window_closed = object - self.assertTrue(self.probe_miss in cm.exception.args[0]) + self.assertTrue(self.probe in cm.exception.args[0]) def testDocIsWorking(self): """ diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp index 814d0ceab..04eb974f0 100644 --- a/sources/shiboken6/libshiboken/signature/signature.cpp +++ b/sources/shiboken6/libshiboken/signature/signature.cpp @@ -248,6 +248,9 @@ PyObject *get_signature_intern(PyObject *ob, PyObject *modifier) return pyside_tp_get___signature__(ob, modifier); if (Py_TYPE(ob) == &PyWrapperDescr_Type) return pyside_wd_get___signature__(ob, modifier); + // For classmethods we use the simple wrapper description implementation. + if (Py_TYPE(ob) == &PyClassMethodDescr_Type) + return pyside_wd_get___signature__(ob, modifier); return nullptr; } |