From f16328b8705f39a10216356d3c14f28607f62a72 Mon Sep 17 00:00:00 2001 From: Boxiang Sun Date: Wed, 4 Jul 2018 06:49:04 +0800 Subject: Remove Py_TPFLAGS_HAVE_VERSION_TAG in Python 3 The Py_TPFLAGS_DEFAULT in Python 3 has the Py_TPFLAGS_HAVE_VERSION_TAG flag, which causes the type attribute cache in _PyType_Lookup. According to the Shiboken implementation for Python 2, this is not we expected. So remove the Py_TPFLAGS_HAVE_VERSION_TAG flag from Py_TPFLAGS_DEFAULT in Python 3. Task-number: PYSIDE-60 Change-Id: Id731a59b65640eb5adea56fe06e0deb58ac4a168 Reviewed-by: Christian Tismer --- sources/shiboken2/libshiboken/sbkpython.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sources/shiboken2') diff --git a/sources/shiboken2/libshiboken/sbkpython.h b/sources/shiboken2/libshiboken/sbkpython.h index a26c318d1..fbac016eb 100644 --- a/sources/shiboken2/libshiboken/sbkpython.h +++ b/sources/shiboken2/libshiboken/sbkpython.h @@ -71,6 +71,12 @@ #define PyInt_AsSsize_t(x) PyLong_AsSsize_t(x) #define PyString_Type PyUnicode_Type + // In Python 3, Py_TPFLAGS_DEFAULT contains Py_TPFLAGS_HAVE_VERSION_TAG, + // which will trigger the attribute cache, which is not intended in Qt for Python. + // Use a customized Py_TPFLAGS_DEFAULT by defining Py_TPFLAGS_HAVE_VERSION_TAG = 0. + #undef Py_TPFLAGS_HAVE_VERSION_TAG + #define Py_TPFLAGS_HAVE_VERSION_TAG (0) + #else // Note: if there wasn't for the old-style classes, only a PyNumber_Check would suffice. #define SbkNumber_Check(X) \ -- cgit v1.2.3