Commit 9eb978cc authored by Stefan Behnel's avatar Stefan Behnel

add necessary cast for Py3.7

see https://bugs.python.org/issue28769
parent b906eb87
...@@ -228,14 +228,18 @@ static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_ ...@@ -228,14 +228,18 @@ static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_
if (PyUnicode_IS_ASCII(o)) { if (PyUnicode_IS_ASCII(o)) {
// cached for the lifetime of the object // cached for the lifetime of the object
*length = PyUnicode_GET_LENGTH(o); *length = PyUnicode_GET_LENGTH(o);
return PyUnicode_AsUTF8(o); // Py3.7 returns a "const char*", need to cast to "char*" for backwards compatibility
// see https://bugs.python.org/issue28769
return (char*) PyUnicode_AsUTF8(o);
} else { } else {
// raise the error // raise the error
PyUnicode_AsASCIIString(o); PyUnicode_AsASCIIString(o);
return NULL; return NULL;
} }
#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ #else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
return PyUnicode_AsUTF8AndSize(o, length); // Py3.7 returns a "const char*", need to cast to "char*" for backwards compatibility
// see https://bugs.python.org/issue28769
return (char*) PyUnicode_AsUTF8AndSize(o, length);
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
#endif /* PY_VERSION_HEX < 0x03030000 */ #endif /* PY_VERSION_HEX < 0x03030000 */
} else } else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment