From: Georg Brandl Date: Fri, 30 May 2008 12:02:38 +0000 (+0000) Subject: Don't return the same object from trivial replace() cases -- X-Git-Tag: v3.0b1~191 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e7217de49d06130bb7a68c1d21868f9ad85cd2f;p=python Don't return the same object from trivial replace() cases -- it is guaranteed to return a new bytearray. --- diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 744e6a9ef2..1442c72732 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -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));