]> granicus.if.org Git - python/commitdiff
Don't return the same object from trivial replace() cases --
authorGeorg Brandl <georg@python.org>
Fri, 30 May 2008 12:02:38 +0000 (12:02 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 30 May 2008 12:02:38 +0000 (12:02 +0000)
it is guaranteed to return a new bytearray.

Objects/bytearrayobject.c

index 744e6a9ef25d20c6c3fef74f951d1b5b49419f69..1442c7273237595687aabcba28de44b82b0990b5 100644 (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));