diff options
author | Christian Tismer <tismer@stackless.com> | 2021-12-07 15:55:14 +0100 |
---|---|---|
committer | Simo Fält <simo.falt@qt.io> | 2021-12-08 12:36:12 +0200 |
commit | 74ddf907ec658aaaeb6fabc7733d7429bc42a3e8 (patch) | |
tree | fc963707930645b316c8528f071e298db025bb4c | |
parent | 71ceb878544a51c5e518641cd366ddcdc73ed8fe (diff) |
Signature: fix the __doc__ attribute of classes
The signature module had been changed to no longer default
the __doc__ attribute of classes to the __init__ signature.
This has the side effect of crashing "help(QtCore)".
Fixed by correct defaults in C++ (AttributeError) and by
setting a "None" default in the Python handler.
The make_helptest function defaults again correctly to the signature:
>>> errorhandler.make_helptext(QtWidgets.QApplication)
'QApplication(self) -> None\nQApplication(self, arg__1: Sequence[str]) -> None'
Change-Id: I140f2b940f98eb126541b18b0feb312c7c4e9728
Fixes: PYSIDE-1727
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
(cherry picked from commit 8901719fd74ce8d8909608365e68f7354adaa254)
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
3 files changed, 13 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 72452a588..4a515c800 100644 --- a/sources/pyside6/tests/QtCore/errormessages_with_features_test.py +++ b/sources/pyside6/tests/QtCore/errormessages_with_features_test.py @@ -46,9 +46,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) +from PySide6 import QtCore from PySide6.QtWidgets import QApplication, QLabel from PySide6.support import __feature__ +import inspect + """ errormessages_with_features_test.py ----------------------------------- @@ -120,6 +123,13 @@ class ErrormessagesWithFeatures(unittest.TestCase): qApp.quit_on_last_window_closed = object self.assertTrue(self.probe_miss in cm.exception.args[0]) + def testDocIsWorking(self): + """ + make sure that it does not crash when touched + """ + inspect.getdoc(QApplication) + inspect.getdoc(QtCore) + if __name__ == '__main__': unittest.main() diff --git a/sources/shiboken6/libshiboken/signature/signature_extend.cpp b/sources/shiboken6/libshiboken/signature/signature_extend.cpp index 4b67d778f..c7aedef08 100644 --- a/sources/shiboken6/libshiboken/signature/signature_extend.cpp +++ b/sources/shiboken6/libshiboken/signature/signature_extend.cpp @@ -173,10 +173,8 @@ static PyObject *handle_doc(PyObject *ob, PyObject *old_descr) pyside_globals->make_helptext_func, "(O)", ob); handle_doc_in_progress--; - if (res == nullptr) { - PyErr_Print(); - Py_FatalError("handle_doc did not receive a result"); - } + if (res == nullptr) + PyErr_Format(PyExc_AttributeError, "%R object has no `__doc__` attribute", ob); return res; } diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py index 4c436eafd..6cab8746f 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py @@ -156,7 +156,7 @@ def check_string_type(s): def make_helptext(func): - existing_doc = func.__doc__ + existing_doc = func.__doc__ if hasattr(func, "__doc__") else None sigs = get_signature(func) if not sigs: return existing_doc |