diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-09-03 09:36:37 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-09-05 14:12:06 +0200 |
| commit | f06b623e5883435bb78438dd46a713d91026eb21 (patch) | |
| tree | aa0e732be39460a5a64d24deff03cf909e08b1f7 /sources/pyside6/libpyside/pysidesignal.cpp | |
| parent | d3e621d1a2842ce597f4311184e0d6835d8c5ecb (diff) | |
Reduce usage of PyTypeObject::tp_name
In the Limited API, PyTypeObject is an opaque struct, for which
libshiboken provides a dummy definition.
PyType_GetFullyQualifiedName() (stable API since 3.13) can be used as
a replacement, but it returns a PyObject.
Add a convenience function PepType_GetFullyQualifiedNameStr() similar
to the existing PepType_GetNameStr() to return a C-string.
Leave the 3.13 code commented out for the moment since it causes a
crash.
This does not cover occurrences of tp_name passed as strings
to Python formatting functions using the %s placeholder since that
can be replaced by the new %N/%T placeholder starting from 3.13.
Task-number: PYSIDE-3171
Change-Id: I4a073872cd0d138b8d8c6aafb08ccb33451812ca
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6/libpyside/pysidesignal.cpp')
| -rw-r--r-- | sources/pyside6/libpyside/pysidesignal.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp index fdb15040c..16a7c9c29 100644 --- a/sources/pyside6/libpyside/pysidesignal.cpp +++ b/sources/pyside6/libpyside/pysidesignal.cpp @@ -99,7 +99,7 @@ static bool connection_Check(PyObject *o) static QByteArray typeName = QByteArrayLiteral("PySide") + QByteArray::number(QT_VERSION_MAJOR) + QByteArrayLiteral(".QtCore.QMetaObject.Connection"); - return std::strcmp(o->ob_type->tp_name, typeName.constData()) == 0; + return std::strcmp(PepType_GetFullyQualifiedNameStr(Py_TYPE(o)), typeName.constData()) == 0; } static std::optional<QByteArrayList> parseArgumentNames(PyObject *argArguments) @@ -450,7 +450,7 @@ static FunctionArgumentsResult extractFunctionArgumentsFromSlot(PyObject *slot) // it being actually being that. if (ret.objCode == nullptr) ret.function = nullptr; - } else if (std::strcmp(Py_TYPE(slot)->tp_name, "compiled_function") == 0) { + } else if (std::strcmp(PepType_GetFullyQualifiedNameStr(Py_TYPE(slot)), "compiled_function") == 0) { ret.isMethod = false; ret.function = slot; @@ -541,7 +541,8 @@ static PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject return nullptr; Qt::ConnectionType connectionType = Qt::AutoConnection; - if (type != nullptr && qstrcmp(Py_TYPE(type)->tp_name, "ConnectionType") == 0) { + if (type != nullptr + && qstrcmp(PepType_GetFullyQualifiedNameStr(Py_TYPE(type)), "ConnectionType") == 0) { static SbkConverter *connectionTypeConv = Shiboken::Conversions::getConverter("Qt::ConnectionType"); Q_ASSERT(connectionTypeConv); |
