Commit 7ce24bc7 authored by Stefan Behnel's avatar Stefan Behnel

Replace usage of the seemingly CPython-internal Py_ISSPACE() macro by a...

Replace usage of the seemingly CPython-internal Py_ISSPACE() macro by a dedicated inline function to make it work in C++ (where Py_ISSPACE() fails to link).

Closes https://github.com/cython/cython/issues/4111
Closes https://github.com/cython/cython/pull/4112
parent 26c909bb
......@@ -784,10 +784,6 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(Py_ISSPACE)
#define Py_ISSPACE(c) Py_UNICODE_ISSPACE(c)
#endif
// ("..." % x) must call PyNumber_Remainder() if x is a string subclass that implements "__rmod__()".
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
......
......@@ -897,6 +897,12 @@ parse_failure:
return -1.0;
}
static CYTHON_INLINE int __Pyx__PyBytes_AsDouble_IsSpace(char ch) {
// see Py_ISSPACE() in CPython
// https://github.com/python/cpython/blob/master/Python/pyctype.c
return (ch == 0x20) | !((ch < 0x9) | (ch > 0xd));
}
static CYTHON_UNUSED double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length) {
double value;
Py_ssize_t i, digits;
......@@ -904,9 +910,9 @@ static CYTHON_UNUSED double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* s
char *end;
// strip spaces at start and end
while (Py_ISSPACE(*start))
while (__Pyx__PyBytes_AsDouble_IsSpace(*start))
start++;
while (start < last - 1 && Py_ISSPACE(last[-1]))
while (start < last - 1 && __Pyx__PyBytes_AsDouble_IsSpace(last[-1]))
last--;
length = last - start;
if (unlikely(length <= 0)) goto fallback;
......
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