diff options
-rw-r--r-- | sources/shiboken2/libshiboken/pep384impl.h | 5 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/pep384impl_doc.rst | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/sources/shiboken2/libshiboken/pep384impl.h b/sources/shiboken2/libshiboken/pep384impl.h index ffbc570a8..93f718988 100644 --- a/sources/shiboken2/libshiboken/pep384impl.h +++ b/sources/shiboken2/libshiboken/pep384impl.h @@ -201,7 +201,12 @@ LIBSHIBOKEN_API int Pep_GetVerboseFlag(void); LIBSHIBOKEN_API char *_PepUnicode_AsString(PyObject *); +#if PY_VERSION_HEX < 0x03000000 #define PyUnicode_GET_SIZE(op) PyUnicode_GetSize((PyObject *)(op)) +#else +// PyUnicode_GetSize is deprecated in favor of PyUnicode_GetLength +#define PyUnicode_GET_SIZE(op) PyUnicode_GetLength((PyObject *)(op)) +#endif #else #define _PepUnicode_AsString PyUnicode_AsUTF8 diff --git a/sources/shiboken2/libshiboken/pep384impl_doc.rst b/sources/shiboken2/libshiboken/pep384impl_doc.rst index ab286dd3e..2f3b7ea97 100644 --- a/sources/shiboken2/libshiboken/pep384impl_doc.rst +++ b/sources/shiboken2/libshiboken/pep384impl_doc.rst @@ -70,7 +70,8 @@ supported. We redefined it as macro ``Py_VerboseFlag`` which calls ``Pep_Verbose unicodeobject.h --------------- -The macro ``PyUnicode_GET_SIZE`` was redefined to call into ``PyUnicode_GetSize``. +The macro ``PyUnicode_GET_SIZE`` was redefined to call into ``PyUnicode_GetSize`` +for Python 2, and ``PyUnicode_GetLength`` for Python 3. Function ``_PyUnicode_AsString`` is unavailable and was replaced by a macro that calls ``_PepUnicode_AsString``. The implementation was a bit involved, and it would be better to change the code and replace this function. |