summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2002-04-15 18:42:15 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2002-04-15 18:42:15 (GMT)
commit0fe940c862fef8729f07b5686847e7e952b40fe6 (patch)
tree320a56eae714fc456178ce2e31c44ab754301c1e /Objects/unicodeobject.c
parent8a5e6790d959cac49ab66cf4973b6ab6c3f397fd (diff)
downloadcpython-0fe940c862fef8729f07b5686847e7e952b40fe6.zip
cpython-0fe940c862fef8729f07b5686847e7e952b40fe6.tar.gz
cpython-0fe940c862fef8729f07b5686847e7e952b40fe6.tar.bz2
Return the orginal string only if it's a real str or unicode
instance, otherwise make a copy.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 361612b..29ba2e4 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;