mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Add the fix for issue 4509 to the mapping methods.
This commit is contained in:
parent
1d2e8b90cc
commit
47137250ff
2 changed files with 32 additions and 27 deletions
|
|
@ -1699,6 +1699,16 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
if ((step > 0 && stop < start) ||
|
||||
(step < 0 && stop > start))
|
||||
stop = start;
|
||||
|
||||
/* Issue #4509: If the array has exported buffers and the slice
|
||||
assignment would change the size of the array, fail early to make
|
||||
sure we don't modify it. */
|
||||
if ((needed == 0 || slicelength != needed) && self->ob_exports > 0) {
|
||||
PyErr_SetString(PyExc_BufferError,
|
||||
"cannot resize an array that is exporting buffers");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (step == 1) {
|
||||
if (slicelength > needed) {
|
||||
memmove(self->ob_item + (start + needed) * itemsize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue