From 4281bc61bdb7dad335d0f83eece249217e57af60 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 29 Apr 2019 15:22:18 +0200 Subject: Use PyUnicode_GetLength instead of PyUnicode_GetSize The function PyUnicode_GetSize is deprecated. Change-Id: I0bc0acd35424f29e1f5154deb0429dab5a4aabd4 Reviewed-by: Friedemann Kleint Reviewed-by: Christian Tismer --- sources/shiboken2/libshiboken/pep384impl.h | 5 +++++ sources/shiboken2/libshiboken/pep384impl_doc.rst | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'sources/shiboken2') 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. -- cgit v1.2.3