summaryrefslogtreecommitdiff
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 c4634f7d07..9b6a30a4f9 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -400,10 +400,16 @@ PyObject_Unicode(PyObject *v)
{
PyObject *res;
PyObject *func;
+ 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)) {
Py_INCREF(v);
return v;
@@ -443,13 +449,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;
}