diff options
author | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2023-08-01 18:02:53 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2023-08-07 21:44:46 +0200 |
commit | 3a95cdec26c3264c271f21738dbb203b88e8e432 (patch) | |
tree | f2addd8abe212e294cb73895beb87833fb28e384 /sources/shiboken6/libshiboken/signature/signature_extend.cpp | |
parent | a7c4a88f5700ab6f0f7244fbdb44435ba30833af (diff) |
signature: Use __doc__ attribute when provided
Currently, classes that inherit for any Q* has their
__doc__ attribute overridden by None when accessing it
as a class member.
For example:
class A(QObject):
"""Content"""
will return None, when accessing A.__doc__
but when the class is instantiated, it properly works.
Fixed by a slight correction in signature_extend
and extending errorhandler.make_helptext a little.
Fixes: PYSIDE-1884
Change-Id: Ia35158f20768f32dfe89e6be5b519cf951277e68
Pick-to: 6.5
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'sources/shiboken6/libshiboken/signature/signature_extend.cpp')
-rw-r--r-- | sources/shiboken6/libshiboken/signature/signature_extend.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sources/shiboken6/libshiboken/signature/signature_extend.cpp b/sources/shiboken6/libshiboken/signature/signature_extend.cpp index e343c7786..ca560d00f 100644 --- a/sources/shiboken6/libshiboken/signature/signature_extend.cpp +++ b/sources/shiboken6/libshiboken/signature/signature_extend.cpp @@ -121,13 +121,15 @@ static PyObject *handle_doc(PyObject *ob, PyObject *old_descr) { AutoDecRef ob_type_mod(GetClassOrModOf(ob)); const char *name; - if (PyModule_Check(ob_type_mod.object())) + bool isModule = PyModule_Check(ob_type_mod.object()); + if (isModule) name = PyModule_GetName(ob_type_mod.object()); else name = reinterpret_cast<PyTypeObject *>(ob_type_mod.object())->tp_name; PyObject *res{}; - if (handle_doc_in_progress || name == nullptr || strncmp(name, "PySide6.", 8) != 0) { + if (handle_doc_in_progress || name == nullptr + || (isModule && strncmp(name, "PySide6.", 8) != 0)) { res = PyObject_CallMethodObjArgs(old_descr, PyMagicName::get(), ob, nullptr); } else { handle_doc_in_progress++; |