Commit 1e7217de authored by Georg Brandl's avatar Georg Brandl

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

it is guaranteed to return a new bytearray.
parent 17cb8a85
...@@ -1459,10 +1459,7 @@ done: ...@@ -1459,10 +1459,7 @@ done:
Py_LOCAL(PyByteArrayObject *) Py_LOCAL(PyByteArrayObject *)
return_self(PyByteArrayObject *self) return_self(PyByteArrayObject *self)
{ {
if (PyByteArray_CheckExact(self)) { /* always return a new bytearray */
Py_INCREF(self);
return (PyByteArrayObject *)self;
}
return (PyByteArrayObject *)PyByteArray_FromStringAndSize( return (PyByteArrayObject *)PyByteArray_FromStringAndSize(
PyByteArray_AS_STRING(self), PyByteArray_AS_STRING(self),
PyByteArray_GET_SIZE(self)); PyByteArray_GET_SIZE(self));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment