diff options
| author | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-17 08:48:43 +0200 |
|---|---|---|
| committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-17 08:56:24 +0200 |
| commit | 01451895b9ddb5cb01fde42c392244d50e8ff137 (patch) | |
| tree | 79fa89bc1c5d08b0257fecaf093716249710c4bb | |
| parent | 56c382f64bebb2a8423be37259d028fee9b0dfb6 (diff) | |
| download | cython-01451895b9ddb5cb01fde42c392244d50e8ff137.tar.gz | |
Convert Py2 str to unicode directly when building fused function signature.
| -rw-r--r-- | Cython/Utility/CythonFunction.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Cython/Utility/CythonFunction.c b/Cython/Utility/CythonFunction.c index 9cf504c84..bde71c49c 100644 --- a/Cython/Utility/CythonFunction.c +++ b/Cython/Utility/CythonFunction.c @@ -1133,18 +1133,18 @@ __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type) } static PyObject * -_obj_to_str(PyObject *obj) +_obj_to_string(PyObject *obj) { if (PyUnicode_CheckExact(obj)) return __Pyx_NewRef(obj); #if PY_MAJOR_VERSION == 2 - else if (PyString_CheckExact(obj)) - return __Pyx_NewRef(obj); + else if (PyString_Check(obj)) + return PyUnicode_FromEncodedObject(obj, NULL, "strict"); #endif else if (PyType_Check(obj)) return PyObject_GetAttr(obj, PYIDENT("__name__")); else - return PyObject_Str(obj); + return PyObject_Unicode(obj); } static PyObject * @@ -1174,7 +1174,7 @@ __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx) #else PyObject *item = PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err; #endif - string = _obj_to_str(item); + string = _obj_to_string(item); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(item); #endif @@ -1186,7 +1186,7 @@ __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx) __pyx_err:; Py_DECREF(list); } else { - signature = _obj_to_str(idx); + signature = _obj_to_string(idx); } if (unlikely(!signature)) |
