Simplify PyObject_Unicode(NULL) by using

PyUnicode_FromString().
This commit is contained in:
Walter Dörwald 2007-05-11 17:25:52 +00:00
parent 0368b726a1
commit b03ccc0472
1 changed files with 3 additions and 8 deletions

View File

@ -435,14 +435,9 @@ PyObject_Unicode(PyObject *v)
PyObject *str;
static PyObject *unicodestr;
if (v == NULL) {
res = PyString_FromString("<NULL>");
if (res == NULL)
return NULL;
str = PyUnicode_FromEncodedObject(res, NULL, "strict");
Py_DECREF(res);
return str;
} else if (PyUnicode_CheckExact(v)) {
if (v == NULL)
return PyUnicode_FromString("<NULL>");
else if (PyUnicode_CheckExact(v)) {
Py_INCREF(v);
return v;
}