diff options
Diffstat (limited to 'sources/shiboken2/libshiboken/pep384impl.h')
-rw-r--r-- | sources/shiboken2/libshiboken/pep384impl.h | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/sources/shiboken2/libshiboken/pep384impl.h b/sources/shiboken2/libshiboken/pep384impl.h index 6d0fa2450..e735095e8 100644 --- a/sources/shiboken2/libshiboken/pep384impl.h +++ b/sources/shiboken2/libshiboken/pep384impl.h @@ -40,8 +40,6 @@ #ifndef PEP384IMPL_H #define PEP384IMPL_H -#include "sbkpython.h" - extern "C" { @@ -204,17 +202,36 @@ LIBSHIBOKEN_API int Pep_GetVerboseFlag(void); * RESOLVED: unicodeobject.h * */ -#ifdef Py_LIMITED_API - -LIBSHIBOKEN_API char *_PepUnicode_AsString(PyObject *); +/////////////////////////////////////////////////////////////////////// +// +// PYSIDE-813: About The Length Of Unicode Objects +// ----------------------------------------------- +// +// In Python 2 and before Python 3.3, the macro PyUnicode_GET_SIZE +// worked fine and really like a macro. +// +// Meanwhile, the unicode objects have changed their layout very much, +// and the former cheap macro call has become a real function call +// that converts objects and needs PyMemory. +// +// That is not only inefficient, but also requires the GIL! +// This problem was visible by debug Python and qdatastream_test.py . +// It was found while fixing the refcount problem of PYSIDE-813 which +// needed a debug Python. +// + +// PyUnicode_GetSize is deprecated in favor of PyUnicode_GetLength. #if PY_VERSION_HEX < 0x03000000 -#define PyUnicode_GET_SIZE(op) PyUnicode_GetSize((PyObject *)(op)) +#define PepUnicode_GetLength(op) PyUnicode_GetSize((PyObject *)(op)) #else -// PyUnicode_GetSize is deprecated in favor of PyUnicode_GetLength -#define PyUnicode_GET_SIZE(op) PyUnicode_GetLength((PyObject *)(op)) +#define PepUnicode_GetLength(op) PyUnicode_GetLength((PyObject *)(op)) #endif +#ifdef Py_LIMITED_API + +LIBSHIBOKEN_API char *_PepUnicode_AsString(PyObject *); + #else #define _PepUnicode_AsString PyUnicode_AsUTF8 #endif @@ -262,6 +279,17 @@ LIBSHIBOKEN_API char *_PepUnicode_AsString(PyObject *); /***************************************************************************** * + * RESOLVED: dictobject.h + * + * PYSIDE-803, PYSIDE-813: We need PyDict_GetItemWithError in order to + * avoid the GIL. + */ +#if PY_VERSION_HEX < 0x03000000 +LIBSHIBOKEN_API PyObject *PyDict_GetItemWithError(PyObject *mp, PyObject *key); +#endif + +/***************************************************************************** + * * RESOLVED: methodobject.h * */ |