diff options
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 361612b16f..29ba2e4498 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4841,8 +4841,15 @@ unicode_zfill(PyUnicodeObject *self, PyObject *args) return NULL; if (self->length >= width) { - Py_INCREF(self); - return (PyObject*) self; + if (PyUnicode_CheckExact(self)) { + Py_INCREF(self); + return (PyObject*) self; + } + else + return PyUnicode_FromUnicode( + PyUnicode_AS_UNICODE(self), + PyUnicode_GET_SIZE(self) + ); } fill = width - self->length; |