aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpyside/signalmanager.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-04-18 18:58:18 +0200
committerChristian Tismer <tismer@stackless.com>2021-12-03 10:12:21 +0100
commite85db57ecf9e998206eefe93433ee58c6f8c1f47 (patch)
tree2cf89e0b03b87500f96ee4e4690b89cacd7c5737 /sources/pyside6/libpyside/signalmanager.cpp
parent79ec52558acc48b0c368738bf1fcc5195921cafb (diff)
PyPySide: Avoid direct access to `op->ob_dict` in PyPy
PyPy treats `op->ob_dict` specially. When you use PyObject_SetAttr and look later for the attribute in the object's dict, you cannot find it. PySide uses direct access to `ob_dict` which has this side effect and was a major obstacle until the PyPy people explained the undocumented behavior. We either need to use a different attribute name than "ob_dict", or use the C API for dict access. The second, simpler solution turned out to be sufficient. Since the used function is in the Stable ABI in version Python 3.10 only, we implemented a replacement function in basewrapper. This change was crucial and led to the first public version. [ChangeLog][shiboken6] PyPySide: Direct access to `op->ob_dict` needed to be avoided in PyPy. This important change took the project far enough to publish it as a preview and to produce wheels. Task-number: PYSIDE-535 Change-Id: I09c59e7ebf78837868912cfd19330256eea71237 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/libpyside/signalmanager.cpp')
-rw-r--r--sources/pyside6/libpyside/signalmanager.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/sources/pyside6/libpyside/signalmanager.cpp b/sources/pyside6/libpyside/signalmanager.cpp
index c1147bb3c..05769f213 100644
--- a/sources/pyside6/libpyside/signalmanager.cpp
+++ b/sources/pyside6/libpyside/signalmanager.cpp
@@ -525,8 +525,8 @@ int SignalManager::registerMetaMethodGetIndex(QObject *source, const char *signa
qWarning() << "Invalid Signal signature:" << signature;
return -1;
}
- auto pySelf = reinterpret_cast<PyObject *>(self);
- PyObject *dict = self->ob_dict;
+ auto *pySelf = reinterpret_cast<PyObject *>(self);
+ auto *dict = SbkObject_GetDict(pySelf);
MetaObjectBuilder *dmo = metaBuilderFromDict(dict);
// Create a instance meta object
@@ -555,7 +555,8 @@ const QMetaObject *SignalManager::retrieveMetaObject(PyObject *self)
// m_dirty flag is set.
Q_ASSERT(self);
- MetaObjectBuilder *builder = metaBuilderFromDict(reinterpret_cast<SbkObject *>(self)->ob_dict);
+ auto *ob_dict = SbkObject_GetDict(self);
+ MetaObjectBuilder *builder = metaBuilderFromDict(ob_dict);
if (!builder)
builder = &(retrieveTypeUserData(self)->mo);