summaryrefslogtreecommitdiff
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 1af96b109f..6a0eece665 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -2401,8 +2401,15 @@ string_zfill(PyStringObject *self, PyObject *args)
return NULL;
if (PyString_GET_SIZE(self) >= width) {
- Py_INCREF(self);
- return (PyObject*) self;
+ if (PyString_CheckExact(self)) {
+ Py_INCREF(self);
+ return (PyObject*) self;
+ }
+ else
+ return PyString_FromStringAndSize(
+ PyString_AS_STRING(self),
+ PyString_GET_SIZE(self)
+ );
}
fill = width - PyString_GET_SIZE(self);