diff options
author | Georg Brandl <georg@python.org> | 2009-08-13 09:05:38 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-08-13 09:05:38 (GMT) |
commit | df475156f430a5f3fa78f5163bb346ec350ac430 (patch) | |
tree | 33f0ec58868af0a80cef95f823f1375a00da38b6 /Modules | |
parent | ae83d6ee371b5e6aeebe303fb853f5c45638414c (diff) | |
download | cpython-df475156f430a5f3fa78f5163bb346ec350ac430.zip cpython-df475156f430a5f3fa78f5163bb346ec350ac430.tar.gz cpython-df475156f430a5f3fa78f5163bb346ec350ac430.tar.bz2 |
Merged revisions 73862,73872 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r73862 | alexandre.vassalotti | 2009-07-05 21:57:00 +0200 (So, 05 Jul 2009) | 2 lines
Add the fix for issue 4509 to the mapping methods.
........
r73872 | gregory.p.smith | 2009-07-07 07:06:04 +0200 (Di, 07 Jul 2009) | 2 lines
Add a unittest for r73566.
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/arraymodule.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index c1a0f53..b24b4c9 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -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, |