summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-05-30 12:02:38 (GMT)
committerGeorg Brandl <georg@python.org>2008-05-30 12:02:38 (GMT)
commit1e7217de49d06130bb7a68c1d21868f9ad85cd2f (patch)
treec177c2958abadc085e769710cec72037080ab317
parent17cb8a85d4931d60fc6f4a2f692514dd77e8d700 (diff)
downloadcpython-1e7217de49d06130bb7a68c1d21868f9ad85cd2f.zip
cpython-1e7217de49d06130bb7a68c1d21868f9ad85cd2f.tar.gz
cpython-1e7217de49d06130bb7a68c1d21868f9ad85cd2f.tar.bz2
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 744e6a9..1442c72 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));