[issue19568] bytearray_setslice_linear() leaves the bytearray in an inconsistent state on memory allocation failure

Serhiy Storchaka report at bugs.python.org
Thu Nov 14 16:03:59 CET 2013


Serhiy Storchaka added the comment:

> With the patch, the deletion succeeded even if you get a MemoryError. The bytearray object is consistent. It's just that its buffer could be smaller (it wastes memory).

Yes, but if a MemoryError occurred during slice assignment b[3:6] = b'ab', the bytearray will be not consistent. For consistency we should copy replacement bytes.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19568>
_______________________________________


More information about the Python-bugs-list mailing list