Commit 01451895 authored by Stefan Behnel's avatar Stefan Behnel

Convert Py2 str to unicode directly when building fused function signature.

parent 56c382f6
...@@ -1133,18 +1133,18 @@ __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type) ...@@ -1133,18 +1133,18 @@ __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
} }
static PyObject * static PyObject *
_obj_to_str(PyObject *obj) _obj_to_string(PyObject *obj)
{ {
if (PyUnicode_CheckExact(obj)) if (PyUnicode_CheckExact(obj))
return __Pyx_NewRef(obj); return __Pyx_NewRef(obj);
#if PY_MAJOR_VERSION == 2 #if PY_MAJOR_VERSION == 2
else if (PyString_CheckExact(obj)) else if (PyString_Check(obj))
return __Pyx_NewRef(obj); return PyUnicode_FromEncodedObject(obj, NULL, "strict");
#endif #endif
else if (PyType_Check(obj)) else if (PyType_Check(obj))
return PyObject_GetAttr(obj, PYIDENT("__name__")); return PyObject_GetAttr(obj, PYIDENT("__name__"));
else else
return PyObject_Str(obj); return PyObject_Unicode(obj);
} }
static PyObject * static PyObject *
...@@ -1174,7 +1174,7 @@ __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx) ...@@ -1174,7 +1174,7 @@ __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx)
#else #else
PyObject *item = PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err; PyObject *item = PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err;
#endif #endif
string = _obj_to_str(item); string = _obj_to_string(item);
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
Py_DECREF(item); Py_DECREF(item);
#endif #endif
...@@ -1186,7 +1186,7 @@ __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx) ...@@ -1186,7 +1186,7 @@ __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx)
__pyx_err:; __pyx_err:;
Py_DECREF(list); Py_DECREF(list);
} else { } else {
signature = _obj_to_str(idx); signature = _obj_to_string(idx);
} }
if (unlikely(!signature)) if (unlikely(!signature))
......
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