From: Christian Tismer Date: Wed, 23 Dec 2020 11:28:16 +0000 (+0200) Subject: qApp: fix flag handling in Python 3.8+ and a Python 3.9 issue X-Git-Tag: archive/raspbian/5.15.2-2+rpi1^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=60a6ad9eeffe4e833992f688655ec305e9e84138;p=pyside2.git qApp: fix flag handling in Python 3.8+ and a Python 3.9 issue This is an old problem that was solved for Python 2.7. From Python 3.8 on, the behavior is the same with Python 3. The fix finally was to extend a Python 2.7 patch to Python 3 as well. See the Jira issue for details. This patch includes also a small patch that was mentioned as necessary for Python 3.9: Python issue 40217. I have seen no effect of this change yet but applied the patch, anyway. Origin: https://codereview.qt-project.org/c/pyside/pyside-setup/+/328046 Gbp-Pq: Name qApp-fix-flag-handling.patch --- diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index d866d13..b38fb3a 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -319,6 +319,11 @@ static int SbkObject_traverse(PyObject *self, visitproc visit, void *arg) if (sbkSelf->ob_dict) Py_VISIT(sbkSelf->ob_dict); + +#if PY_VERSION_HEX >= 0x03090000 + // This was not needed before Python 3.9 (Python issue 35810 and 40217) + Py_VISIT(Py_TYPE(self)); +#endif return 0; } @@ -769,12 +774,15 @@ PyObject *SbkQAppTpNew(PyTypeObject *subtype, PyObject *, PyObject *) // PYSIDE-560: // We avoid to use this in Python 3, because we have a hard time to get // write access to these flags -#ifndef IS_PY3K + + // PYSIDE-1447: + // Since Python 3.8, we have the same weird flags handling in Python 3.8 + // as well. The singleton Python is no longer needed and we could remove + // the whole special handling, maybe in another checkin. if (PyType_HasFeature(subtype, Py_TPFLAGS_HAVE_GC)) { subtype->tp_flags &= ~Py_TPFLAGS_HAVE_GC; subtype->tp_free = PyObject_Del; } -#endif auto self = reinterpret_cast(MakeQAppWrapper(subtype)); return self == nullptr ? nullptr : _setupNew(self, subtype); }