summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-08-13 09:04:31 (GMT)
committerGeorg Brandl <georg@python.org>2009-08-13 09:04:31 (GMT)
commitae83d6ee371b5e6aeebe303fb853f5c45638414c (patch)
tree6ce42b81661f4d7432af393ba303fca20884650b /Modules
parent3deeed9a3250dfa1eab6b03db357ce188d512f64 (diff)
downloadcpython-ae83d6ee371b5e6aeebe303fb853f5c45638414c.zip
cpython-ae83d6ee371b5e6aeebe303fb853f5c45638414c.tar.gz
cpython-ae83d6ee371b5e6aeebe303fb853f5c45638414c.tar.bz2
Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k ................ r73833 | gregory.p.smith | 2009-07-04 04:46:54 +0200 (Sa, 04 Jul 2009) | 20 lines Merged revisions 73825-73826 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r73825 | gregory.p.smith | 2009-07-03 18:49:29 -0700 (Fri, 03 Jul 2009) | 9 lines Use select.poll() in subprocess, when available, rather than select() so that it does not fail when file descriptors are large. Fixes issue3392. Patch largely contributed by Frank Chu (fpmc) with some improvements by me. See http://bugs.python.org/issue3392. ........ r73826 | gregory.p.smith | 2009-07-03 18:55:11 -0700 (Fri, 03 Jul 2009) | 2 lines news entry for r73825 ........ Candidate for backporting to release31-maint as it is a bug fix and changes no public API. ................ r73838 | gregory.p.smith | 2009-07-04 10:32:15 +0200 (Sa, 04 Jul 2009) | 2 lines change deprecated unittest method calls into their proper names. ................ r73850 | alexandre.vassalotti | 2009-07-05 07:38:18 +0200 (So, 05 Jul 2009) | 3 lines Issue 4509: Do not modify an array if we know the change would result in a failure due to exported buffers. ................ r73851 | alexandre.vassalotti | 2009-07-05 07:47:28 +0200 (So, 05 Jul 2009) | 2 lines Add more test cases to BaseTest.test_memoryview_no_resize. ................ r73852 | alexandre.vassalotti | 2009-07-05 08:25:14 +0200 (So, 05 Jul 2009) | 5 lines Fix array.extend and array.__iadd__ to handle the case where an array is extended with itself. This bug is specific the py3k version of arraymodule.c ................ r73856 | alexandre.vassalotti | 2009-07-05 08:42:44 +0200 (So, 05 Jul 2009) | 6 lines Issue 4005: Remove .sort() call on dict_keys object. This caused pydoc to fail when there was a zip file in sys.path. Patch contributed by Amaury Forgeot d'Arc. ................ r73857 | alexandre.vassalotti | 2009-07-05 08:50:08 +0200 (So, 05 Jul 2009) | 2 lines Add NEWS entries for the changes I made recently. ................
Diffstat (limited to 'Modules')
-rw-r--r--Modules/arraymodule.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 5965cdd..c1a0f53 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -735,6 +735,14 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
ihigh = Py_SIZE(a);
item = a->ob_item;
d = n - (ihigh-ilow);
+ /* 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 (d != 0 && a->ob_exports > 0) {
+ PyErr_SetString(PyExc_BufferError,
+ "cannot resize an array that is exporting buffers");
+ return -1;
+ }
if (d < 0) { /* Delete -d items */
memmove(item + (ihigh+d)*a->ob_descr->itemsize,
item + ihigh*a->ob_descr->itemsize,
@@ -802,8 +810,8 @@ array_iter_extend(arrayobject *self, PyObject *bb)
static int
array_do_extend(arrayobject *self, PyObject *bb)
{
- Py_ssize_t size, oldsize;
-
+ Py_ssize_t size, oldsize, bbsize;
+
if (!array_Check(bb))
return array_iter_extend(self, bb);
#define b ((arrayobject *)bb)
@@ -818,11 +826,13 @@ array_do_extend(arrayobject *self, PyObject *bb)
return -1;
}
oldsize = Py_SIZE(self);
+ /* Get the size of bb before resizing the array since bb could be self. */
+ bbsize = Py_SIZE(bb);
size = oldsize + Py_SIZE(b);
if (array_resize(self, size) == -1)
return -1;
memcpy(self->ob_item + oldsize * self->ob_descr->itemsize,
- b->ob_item, Py_SIZE(b) * b->ob_descr->itemsize);
+ b->ob_item, bbsize * b->ob_descr->itemsize);
return 0;
#undef b