Commit f2955a60 authored by Stefan Behnel's avatar Stefan Behnel

use generic "__Pyx_PyUnicode_READY()" macro instead of checking for PEP393 all over the place

parent bd388a4e
...@@ -1384,10 +1384,8 @@ class UnicodeNode(ConstNode): ...@@ -1384,10 +1384,8 @@ class UnicodeNode(ConstNode):
data_cname, data_cname,
data_cname, data_cname,
code.error_goto_if_null(self.result_code, self.pos))) code.error_goto_if_null(self.result_code, self.pos)))
code.putln("#if CYTHON_PEP393_ENABLED")
code.put_error_if_neg( code.put_error_if_neg(
self.pos, "PyUnicode_READY(%s)" % self.result_code) self.pos, "__Pyx_PyUnicode_READY(%s)" % self.result_code)
code.putln("#endif")
else: else:
self.result_code = code.get_py_string_const(self.value) self.result_code = code.get_py_string_const(self.value)
else: else:
......
...@@ -170,10 +170,8 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int ...@@ -170,10 +170,8 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int
Py_ssize_t length; Py_ssize_t length;
int kind; int kind;
void *data1, *data2; void *data1, *data2;
#if CYTHON_PEP393_ENABLED if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
if (unlikely(PyUnicode_READY(s1) < 0) || unlikely(PyUnicode_READY(s2) < 0))
return -1; return -1;
#endif
length = __Pyx_PyUnicode_GET_LENGTH(s1); length = __Pyx_PyUnicode_GET_LENGTH(s1);
if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
goto return_ne; goto return_ne;
...@@ -346,9 +344,7 @@ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py ...@@ -346,9 +344,7 @@ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py
static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i, static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i,
int wraparound, int boundscheck) { int wraparound, int boundscheck) {
Py_ssize_t length; Py_ssize_t length;
#if CYTHON_PEP393_ENABLED
if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return (Py_UCS4)-1; if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return (Py_UCS4)-1;
#endif
if (wraparound | boundscheck) { if (wraparound | boundscheck) {
length = __Pyx_PyUnicode_GET_LENGTH(ustring); length = __Pyx_PyUnicode_GET_LENGTH(ustring);
if (wraparound & unlikely(i < 0)) i += length; if (wraparound & unlikely(i < 0)) i += length;
...@@ -483,12 +479,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring( ...@@ -483,12 +479,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring( static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
PyObject* text, Py_ssize_t start, Py_ssize_t stop) { PyObject* text, Py_ssize_t start, Py_ssize_t stop) {
Py_ssize_t length; Py_ssize_t length;
#if CYTHON_PEP393_ENABLED if (unlikely(__Pyx_PyUnicode_READY(text) == -1)) return NULL;
if (unlikely(PyUnicode_READY(text) == -1)) return NULL; length = __Pyx_PyUnicode_GET_LENGTH(text);
length = PyUnicode_GET_LENGTH(text);
#else
length = PyUnicode_GET_SIZE(text);
#endif
if (start < 0) { if (start < 0) {
start += length; start += length;
if (start < 0) if (start < 0)
......
...@@ -192,7 +192,7 @@ static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_ ...@@ -192,7 +192,7 @@ static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_
*length = PyBytes_GET_SIZE(defenc); *length = PyBytes_GET_SIZE(defenc);
return defenc_c; return defenc_c;
#else /* PY_VERSION_HEX < 0x03030000 */ #else /* PY_VERSION_HEX < 0x03030000 */
if (PyUnicode_READY(o) == -1) return NULL; if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
if (PyUnicode_IS_ASCII(o)) { if (PyUnicode_IS_ASCII(o)) {
// cached for the lifetime of the object // cached for the lifetime of the object
......
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