Commit 323d9b94 authored by Stefan Behnel's avatar Stefan Behnel

Avoid calling PyUnicode_FromUnicode() in Py3.

Closes https://github.com/cython/cython/pull/3677
parent 9bc3fc65
......@@ -443,6 +443,7 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
/////////////// decode_c_string ///////////////
//@requires: IncludeStringH
//@requires: decode_c_string_utf16
//@substitute: naming
/* duplicate code to avoid calling strlen() if start >= 0 and stop >= 0 */
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
......@@ -467,7 +468,7 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
stop += length;
}
if (unlikely(stop <= start))
return PyUnicode_FromUnicode(NULL, 0);
return __Pyx_NewRef($empty_unicode);
length = stop - start;
cstring += start;
if (decode_func) {
......@@ -486,6 +487,7 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
/////////////// decode_c_bytes ///////////////
//@requires: decode_c_string_utf16
//@substitute: naming
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
......@@ -503,7 +505,7 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
if (stop > length)
stop = length;
if (unlikely(stop <= start))
return PyUnicode_FromUnicode(NULL, 0);
return __Pyx_NewRef($empty_unicode);
length = stop - start;
cstring += start;
if (decode_func) {
......
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