@@ -26,7 +26,6 @@ __all__ = ['Fraction']
2626__version__ = ' 1.23'
2727
2828cimport cython
29- from cpython.unicode cimport Py_UNICODE_TODECIMAL
3029from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
3130from cpython.long cimport PyLong_FromString
3231
@@ -1830,31 +1829,50 @@ cdef _raise_parse_overflow(s):
18301829
18311830cdef extern from * :
18321831 """
1832+ static CYTHON_INLINE int __QUICKTIONS_to_decimal(Py_UCS4 digit) {
1833+ #if CYTHON_COMPILING_IN_LIMITED_API
1834+ #include "todigit.h"
1835+ #else
1836+ return Py_UNICODE_TODECIMAL(digit);
1837+ #endif
1838+ }
1839+
18331840 static CYTHON_INLINE int __QUICKTIONS_unpack_ustring(
18341841 PyObject* string, Py_ssize_t *length, void** data, int *kind) {
1835- if (PyUnicode_READY(string) < 0) return -1;
1836- *kind = PyUnicode_KIND(string);
1837- *length = PyUnicode_GET_LENGTH(string);
1838- *data = PyUnicode_DATA(string);
1842+ if (__Pyx_PyUnicode_READY(string) < 0) return -1;
1843+ *kind = __Pyx_PyUnicode_KIND(string);
1844+ *length = __Pyx_PyUnicode_GET_LENGTH(string);
1845+
1846+ #if CYTHON_COMPILING_IN_LIMITED_API
1847+ *data = (void*) string;
1848+ #else
1849+ *data = __Pyx_PyUnicode_DATA(string);
1850+ #endif
1851+
18391852 return 0;
18401853 }
1854+
1855+ #if CYTHON_COMPILING_IN_LIMITED_API
1856+ #define __QUICKTIONS_char_at(data, kind, index) (Py_UCS4) (((void)kind), PyUnicode_ReadChar(data, index))
1857+ #else
18411858 #define __QUICKTIONS_char_at(data, kind, index) \
18421859 (((kind == 1) ? (Py_UCS4) ((char*) data)[index] : (Py_UCS4) PyUnicode_READ(kind, data, index)))
1860+ #endif
18431861 """
18441862 int _unpack_ustring " __QUICKTIONS_unpack_ustring" (
18451863 object string, Py_ssize_t * length, void ** data, int * kind) except - 1
18461864 Py_UCS4 _char_at " __QUICKTIONS_char_at" (void * data, int kind, Py_ssize_t index)
1847- Py_UCS4 PyUnicode_READ( int kind, void * data, Py_ssize_t index )
1865+ int _to_decimal " __QUICKTIONS_to_decimal " (Py_UCS4 c )
18481866
18491867
1850- cdef inline int _parse_digit(char ** c_digits, Py_UCS4 c, int allow_unicode):
1868+ cdef inline int _parse_digit(char ** c_digits, Py_UCS4 c, int allow_unicode) noexcept :
18511869 cdef unsigned int unum
18521870 cdef int num
18531871 unum = (< unsigned int > c) - < unsigned int > ' 0' # Relies on integer underflow for dots etc.
18541872 if unum > 9 :
18551873 if not allow_unicode:
18561874 return - 1
1857- num = Py_UNICODE_TODECIMAL (c)
1875+ num = _to_decimal (c)
18581876 if num == - 1 :
18591877 return - 1
18601878 unum = < unsigned int > num
0 commit comments