comparison Modules/arraymodule.c @ 55124:7bb7758e6d64

Add the fix for issue 4509 to the mapping methods.
author Alexandre Vassalotti <alexandre@peadrop.com>
date Sun, 05 Jul 2009 19:57:00 +0000
parents a76b34cfc897
children 67f5e01d5a6a
comparison
equal deleted inserted replaced
55123:0522e571ce74 55124:7bb7758e6d64
1697 itemsize = self->ob_descr->itemsize; 1697 itemsize = self->ob_descr->itemsize;
1698 /* for 'a[2:1] = ...', the insertion point is 'start', not 'stop' */ 1698 /* for 'a[2:1] = ...', the insertion point is 'start', not 'stop' */
1699 if ((step > 0 && stop < start) || 1699 if ((step > 0 && stop < start) ||
1700 (step < 0 && stop > start)) 1700 (step < 0 && stop > start))
1701 stop = start; 1701 stop = start;
1702
1703 /* Issue #4509: If the array has exported buffers and the slice
1704 assignment would change the size of the array, fail early to make
1705 sure we don't modify it. */
1706 if ((needed == 0 || slicelength != needed) && self->ob_exports > 0) {
1707 PyErr_SetString(PyExc_BufferError,
1708 "cannot resize an array that is exporting buffers");
1709 return -1;
1710 }
1711
1702 if (step == 1) { 1712 if (step == 1) {
1703 if (slicelength > needed) { 1713 if (slicelength > needed) {
1704 memmove(self->ob_item + (start + needed) * itemsize, 1714 memmove(self->ob_item + (start + needed) * itemsize,
1705 self->ob_item + stop * itemsize, 1715 self->ob_item + stop * itemsize,
1706 (Py_SIZE(self) - stop) * itemsize); 1716 (Py_SIZE(self) - stop) * itemsize);