aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/libshiboken/basewrapper.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-12-23 10:19:23 +0100
committerChristian Tismer <tismer@stackless.com>2022-01-05 15:51:40 +0100
commitd7526db85fcec588fa6ca643bd6fb8a9f45c3fc2 (patch)
tree165a849b190e80d67905b342f15eeff7ed5583ed /sources/shiboken6/libshiboken/basewrapper.cpp
parent981ffb345928cf740a5b751aaef43a266d077d13 (diff)
PyPySide: Do some cleanup and Improvements
For more clarity, the function SbkObject_GetDict is renamed to SbkObject_GetDict_NoRef. The internal __dict__ implementation SbkObjectGetDict is re-written to use SbkObject_GetDict_NoRef, which is more correct because of PyPy's tp_dict handling. Task-number: PYSIDE-535 Change-Id: I28034d9199918859de809fde08c413b4b66a3136 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/libshiboken/basewrapper.cpp')
-rw-r--r--sources/shiboken6/libshiboken/basewrapper.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp
index 7a615b06b..eb8069525 100644
--- a/sources/shiboken6/libshiboken/basewrapper.cpp
+++ b/sources/shiboken6/libshiboken/basewrapper.cpp
@@ -104,7 +104,7 @@ void setDestroyQApplication(DestroyQAppHook func)
}
// PYSIDE-535: Use the C API in PyPy instead of `op->ob_dict`, directly
-LIBSHIBOKEN_API PyObject *SbkObject_GetDict(PyObject *op)
+LIBSHIBOKEN_API PyObject *SbkObject_GetDict_NoRef(PyObject *op)
{
#ifdef PYPY_VERSION
auto *ret = PyObject_GenericGetDict(op, nullptr);
@@ -187,13 +187,9 @@ PyTypeObject *SbkObjectType_TypeF(void)
static PyObject *SbkObjectGetDict(PyObject *pObj, void *)
{
- auto *obj = reinterpret_cast<SbkObject *>(pObj);
- if (!obj->ob_dict)
- obj->ob_dict = PyDict_New();
- if (!obj->ob_dict)
- return nullptr;
- Py_INCREF(obj->ob_dict);
- return obj->ob_dict;
+ auto ret = SbkObject_GetDict_NoRef(pObj);
+ Py_XINCREF(ret);
+ return ret;
}
static PyGetSetDef SbkObjectGetSetList[] = {