Python 3.7 support: Remove use of deprecated PyUnicode_GetSize

This commit is contained in:
William S Fulton 2018-06-15 19:34:36 +01:00
commit 1665712fcb
2 changed files with 9 additions and 1 deletions

View file

@ -16,8 +16,12 @@ Version 4.0.0 (in progress)
instring(b"h\xe9llooo") # Python instring(b"h\xe9llooo") # Python
2018-06-15: wsfulton
[Python] Python 3.7 support: Replace use of deprecated PyUnicode_GetSize with
PyUnicode_GetLength to remove deprecated warnings compiling the C/C++ wrappers.
2018-06-12: wsfulton 2018-06-12: wsfulton
[Python] The %pythonabc feature in pyabc.i now uses base classes [Python] Python 3.7 support: The %pythonabc feature in pyabc.i now uses base classes
collections.abc.MutableSequence collections.abc.MutableSequence
collections.abc.MutableMapping collections.abc.MutableMapping
collections.abc.MutableSet collections.abc.MutableSet

View file

@ -29,7 +29,11 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
} }
%#endif %#endif
if (isunicode) { if (isunicode) {
%#if PY_VERSION_HEX >= 0x03030000
Py_ssize_t len = PyUnicode_GetLength(obj);
%#else
Py_ssize_t len = PyUnicode_GetSize(obj); Py_ssize_t len = PyUnicode_GetSize(obj);
%#endif
if (cptr) { if (cptr) {
Py_ssize_t length; Py_ssize_t length;
*cptr = %new_array(len + 1, wchar_t); *cptr = %new_array(len + 1, wchar_t);