Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b03ccc0

Browse files
committed
Simplify PyObject_Unicode(NULL) by using
PyUnicode_FromString().
1 parent 0368b72 commit b03ccc0

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

Objects/object.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,9 @@ PyObject_Unicode(PyObject *v)
435435
PyObject *str;
436436
static PyObject *unicodestr;
437437

438-
if (v == NULL) {
439-
res = PyString_FromString("<NULL>");
440-
if (res == NULL)
441-
return NULL;
442-
str = PyUnicode_FromEncodedObject(res, NULL, "strict");
443-
Py_DECREF(res);
444-
return str;
445-
} else if (PyUnicode_CheckExact(v)) {
438+
if (v == NULL)
439+
return PyUnicode_FromString("<NULL>");
440+
else if (PyUnicode_CheckExact(v)) {
446441
Py_INCREF(v);
447442
return v;
448443
}

0 commit comments

Comments
 (0)