[Python-checkins] python/dist/src/Objects stringobject.c,2.158,2.159 unicodeobject.c,2.138,2.139
doerwalter@sourceforge.net
doerwalter@sourceforge.net
Mon, 15 Apr 2002 11:42:18 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv5246/Objects
Modified Files:
stringobject.c unicodeobject.c
Log Message:
Return the orginal string only if it's a real str or unicode
instance, otherwise make a copy.
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.158
retrieving revision 2.159
diff -C2 -d -r2.158 -r2.159
*** stringobject.c 15 Apr 2002 13:48:52 -0000 2.158
--- stringobject.c 15 Apr 2002 18:42:15 -0000 2.159
***************
*** 2402,2407 ****
if (PyString_GET_SIZE(self) >= width) {
! Py_INCREF(self);
! return (PyObject*) self;
}
--- 2402,2414 ----
if (PyString_GET_SIZE(self) >= width) {
! if (PyString_CheckExact(self)) {
! Py_INCREF(self);
! return (PyObject*) self;
! }
! else
! return PyString_FromStringAndSize(
! PyString_AS_STRING(self),
! PyString_GET_SIZE(self)
! );
}
Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.138
retrieving revision 2.139
diff -C2 -d -r2.138 -r2.139
*** unicodeobject.c 15 Apr 2002 13:36:47 -0000 2.138
--- unicodeobject.c 15 Apr 2002 18:42:15 -0000 2.139
***************
*** 4842,4847 ****
if (self->length >= width) {
! Py_INCREF(self);
! return (PyObject*) self;
}
--- 4842,4854 ----
if (self->length >= width) {
! if (PyUnicode_CheckExact(self)) {
! Py_INCREF(self);
! return (PyObject*) self;
! }
! else
! return PyUnicode_FromUnicode(
! PyUnicode_AS_UNICODE(self),
! PyUnicode_GET_SIZE(self)
! );
}