aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2019-04-29 15:22:18 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-05-03 12:52:36 +0000
commit4281bc61bdb7dad335d0f83eece249217e57af60 (patch)
treed4794b5011b2959bf38b30ef0839e1145fff04be /sources
parentefb49a91fc4e378b40a9a80470cab7977b866997 (diff)
Use PyUnicode_GetLength instead of PyUnicode_GetSize
The function PyUnicode_GetSize is deprecated. Change-Id: I0bc0acd35424f29e1f5154deb0429dab5a4aabd4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.h5
-rw-r--r--sources/shiboken2/libshiboken/pep384impl_doc.rst3
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.