summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-05-30 12:02:38 +0000
committerGeorg Brandl <georg@python.org>2008-05-30 12:02:38 +0000
commitf52fc8fdc2393b5e22876cb14b9b5e47a5694405 (patch)
treeea429c65d163c3320bab6c12b1eed2adae580924
parentb2c396f969622530d453c8f3f16b27bc6a931f74 (diff)
downloadcpython-f52fc8fdc2393b5e22876cb14b9b5e47a5694405.tar.gz
Don't return the same object from trivial replace() cases --
it is guaranteed to return a new bytearray.
-rw-r--r--Objects/bytearrayobject.c5
1 files changed, 1 insertions, 4 deletions
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));