From d8438d0a3922934fc17671eb45dd7b7377fe37e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Thu, 3 Aug 2023 17:33:41 +0200 Subject: signature: Add support for classmethods Two tests were adapted, because now the missing signature error message: TypeError: xxx.__dict__['yyy'].fset() 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 Reviewed-by: Friedemann Kleint (cherry picked from commit 94869cf1cacb1a5c2d722f49feb8e8af895144bc) Reviewed-by: Qt Cherry-pick Bot --- sources/pyside6/tests/QtCore/errormessages_with_features_test.py | 9 ++++----- 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; } -- cgit v1.2.3