Return the orginal string only if it's a real str or unicode

instance, otherwise make a copy.
This commit is contained in:
Walter Dörwald 2002-04-15 18:42:15 +00:00
parent 8a5e6790d9
commit 0fe940c862
2 changed files with 18 additions and 4 deletions

View file

@ -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;