summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 87aa475..7dbd554 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -373,9 +373,15 @@ PyObject *
PyObject_Unicode(PyObject *v)
{
PyObject *res;
+ PyObject *str;
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)) {
Py_INCREF(v);
return v;
@@ -418,13 +424,9 @@ PyObject_Unicode(PyObject *v)
if (res == NULL)
return NULL;
if (!PyUnicode_Check(res)) {
- PyObject *str;
str = PyUnicode_FromEncodedObject(res, NULL, "strict");
Py_DECREF(res);
- if (str)
- res = str;
- else
- return NULL;
+ res = str;
}
return res;
}