aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpysideremoteobjects
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2025-09-03 09:36:37 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2025-09-05 14:12:06 +0200
commitf06b623e5883435bb78438dd46a713d91026eb21 (patch)
treeaa0e732be39460a5a64d24deff03cf909e08b1f7 /sources/pyside6/libpysideremoteobjects
parentd3e621d1a2842ce597f4311184e0d6835d8c5ecb (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/libpysideremoteobjects')
-rw-r--r--sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp2
-rw-r--r--sources/pyside6/libpysideremoteobjects/pysidedynamiccommon.cpp2
-rw-r--r--sources/pyside6/libpysideremoteobjects/pysidedynamicpod.cpp5
-rw-r--r--sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp2
4 files changed, 6 insertions, 5 deletions
diff --git a/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp b/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp
index d26d0d1bd..571195bcc 100644
--- a/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp
+++ b/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp
@@ -235,7 +235,7 @@ struct ReplicaDefs
PyObject *name = nullptr;
static PyTypeObject *nodeType = Shiboken::Conversions::getPythonTypeObject("QRemoteObjectNode");
if (!PyArg_UnpackTuple(args, "Replica.__init__", 2, 3, &node, &constructorType, &name) ||
- !PySide::inherits(Py_TYPE(node), nodeType->tp_name)) {
+ !PySide::inherits(Py_TYPE(node), PepType_GetFullyQualifiedNameStr(nodeType))) {
PyErr_SetString(PyExc_TypeError,
"Replicas can be initialized with no arguments or by node.acquire only");
return -1;
diff --git a/sources/pyside6/libpysideremoteobjects/pysidedynamiccommon.cpp b/sources/pyside6/libpysideremoteobjects/pysidedynamiccommon.cpp
index 1e8bc3279..b13831207 100644
--- a/sources/pyside6/libpysideremoteobjects/pysidedynamiccommon.cpp
+++ b/sources/pyside6/libpysideremoteobjects/pysidedynamiccommon.cpp
@@ -96,7 +96,7 @@ int create_managed_py_enums(PyObject *self, QMetaObject *meta)
if (PyObject_SetAttrString(self, "_enum_data", enum_data) < 0) {
PyErr_Print();
qWarning() << "Failed to set _enum_data attribute on type"
- << reinterpret_cast<PyTypeObject *>(self)->tp_name;
+ << PepType_GetFullyQualifiedNameStr(reinterpret_cast<PyTypeObject *>(self));
return -1;
}
Py_DECREF(enum_data);
diff --git a/sources/pyside6/libpysideremoteobjects/pysidedynamicpod.cpp b/sources/pyside6/libpysideremoteobjects/pysidedynamicpod.cpp
index be9ec72e4..5dfdb4484 100644
--- a/sources/pyside6/libpysideremoteobjects/pysidedynamicpod.cpp
+++ b/sources/pyside6/libpysideremoteobjects/pysidedynamicpod.cpp
@@ -74,7 +74,7 @@ struct PodDefs
static PyObject *tp_repr(PyObject *self)
{
auto *type = Py_TYPE(self);
- std::string repr(type->tp_name);
+ std::string repr(PepType_GetFullyQualifiedNameStr(type));
repr += "(";
for (Py_ssize_t i = 0; i < PyTuple_Size(self); ++i) {
if (i > 0)
@@ -245,7 +245,8 @@ PyTypeObject *createPodType(QMetaObject *meta)
if (set_cleanup_capsule_attr_for_pointer(type, "_converter_capsule", converter) < 0)
return nullptr;
Shiboken::Conversions::registerConverterName(converter, meta->className());
- Shiboken::Conversions::registerConverterName(converter, type->tp_name);
+ Shiboken::Conversions::registerConverterName(converter,
+ PepType_GetFullyQualifiedNameStr(type));
Shiboken::Conversions::addPythonToCppValueConversion(converter, pythonToCpp_Tuple_POD,
is_Tuple_PythonToCpp_POD_Convertible);
diff --git a/sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp b/sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp
index 5b4859cd0..5804add37 100644
--- a/sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp
+++ b/sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp
@@ -368,7 +368,7 @@ bool instantiateFromDefaultValue(QVariant &variant, const QString &defaultValue)
static PyObject *pyLocals = PyDict_New();
// Create the Python expression to evaluate
- std::string code = std::string(pyType->tp_name) + '('
+ std::string code = std::string(PepType_GetFullyQualifiedNameStr(pyType)) + '('
+ defaultValue.toUtf8().constData() + ')';
PyObject *pyResult = PyRun_String(code.c_str(), Py_eval_input, pyLocals, pyLocals);