From: Christian Tismer Date: Thu, 5 Dec 2019 10:08:50 +0000 (+0100) Subject: [PATCH 2/3] Optimize the Python 3.8 refcount fix a tiny bit X-Git-Tag: archive/raspbian/5.13.2-3+rpi1~1^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8c4a1d411dc990adb7f1b1676e5b96d688c1ee08;p=pyside2.git [PATCH 2/3] Optimize the Python 3.8 refcount fix a tiny bit This change uses the fact that our workaround to temporarily remove the Py_TPFLAGS_METHOD_DESCRIPTOR flag uses the "mro" function of PyType_Type, which never will change. Therefore, the static keyword makes sure that this function lookup happens only once. Change-Id: I44b74556da1fac2596c81339af30cb66218276e2 Reviewed-by: Friedemann Kleint Gbp-Pq: Name 0003-Optimize-the-Python-3.8-refcount-fix-a-tiny-bit.patch --- diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index e9bef07..1e3b740 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -506,7 +506,7 @@ PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *k // PYSIDE-939: This is a temporary patch that circumvents the problem // with Py_TPFLAGS_METHOD_DESCRIPTOR until this is finally solved. PyObject *ob_PyType_Type = reinterpret_cast(&PyType_Type); - PyObject *mro = PyObject_GetAttr(ob_PyType_Type, Shiboken::PyName::mro()); + static PyObject *mro = PyObject_GetAttr(ob_PyType_Type, Shiboken::PyName::mro()); auto hold = Py_TYPE(mro)->tp_flags; Py_TYPE(mro)->tp_flags &= ~Py_TPFLAGS_METHOD_DESCRIPTOR; auto *newType = reinterpret_cast(type_new(metatype, args, kwds));