From e85db57ecf9e998206eefe93433ee58c6f8c1f47 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sun, 18 Apr 2021 18:58:18 +0200 Subject: 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 --- sources/pyside6/libpyside/signalmanager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sources/pyside6/libpyside/signalmanager.cpp') 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(self); - PyObject *dict = self->ob_dict; + auto *pySelf = reinterpret_cast(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(self)->ob_dict); + auto *ob_dict = SbkObject_GetDict(self); + MetaObjectBuilder *builder = metaBuilderFromDict(ob_dict); if (!builder) builder = &(retrieveTypeUserData(self)->mo); -- cgit v1.2.3