instance, otherwise make a copy.
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);
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;