Don't return the same object from trivial replace() cases --

it is guaranteed to return a new bytearray.
This commit is contained in:
Georg Brandl 2008-05-30 12:02:38 +00:00
parent 17cb8a85d4
commit 1e7217de49

View file

@ -1459,10 +1459,7 @@ done:
Py_LOCAL(PyByteArrayObject *)
return_self(PyByteArrayObject *self)
{
if (PyByteArray_CheckExact(self)) {
Py_INCREF(self);
return (PyByteArrayObject *)self;
}
/* always return a new bytearray */
return (PyByteArrayObject *)PyByteArray_FromStringAndSize(
PyByteArray_AS_STRING(self),
PyByteArray_GET_SIZE(self));