mirror of https://github.com/swig/swig
Strict Python stable abi conformance fix for PyUnicode_GetLength
PyUnicode_GetLength is officially documented as being in the stable abi from python-3.7 onwards. It is is actually available in the Python headers when compiling with Py_LIMITED_API set to 0x03030000 (python-3.3) and later. This change ensures it is only used when Py_LIMITED_API is set to 0x03070000 (python-3.7) and later for strict conformance.
This commit is contained in:
parent
29b1bdb8a4
commit
fb41e7290e
|
@ -30,7 +30,11 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
|
|||
%#endif
|
||||
if (isunicode) {
|
||||
%#if PY_VERSION_HEX >= 0x03030000
|
||||
%# if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
|
||||
Py_ssize_t len = PyUnicode_GetLength(obj);
|
||||
%# else
|
||||
Py_ssize_t len = PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), NULL, 0) - 1;
|
||||
%# endif
|
||||
%#else
|
||||
Py_ssize_t len = PyUnicode_GetSize(obj);
|
||||
%#endif
|
||||
|
|
Loading…
Reference in New Issue