summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-07-11 12:12:00 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-07-11 12:12:00 (GMT)
commit1ac745b5c52ab349e58f633d0a9d73cdb0e7b818 (patch)
tree251be9880cf30ccda0e2c89618b2dd4cffe329ba
parent349d558e0d732d49cd1e42e3738496e868f32cfc (diff)
downloadcpython-1ac745b5c52ab349e58f633d0a9d73cdb0e7b818.zip
cpython-1ac745b5c52ab349e58f633d0a9d73cdb0e7b818.tar.gz
cpython-1ac745b5c52ab349e58f633d0a9d73cdb0e7b818.tar.bz2
Issue #7616: Fix copying of overlapping memoryview slices with the Intel
compiler.
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/memoryobject.c14
2 files changed, 6 insertions, 11 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index dbfc4c5..0c11639 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 1?
Core and Builtins
-----------------
+- Issue #7616: Fix copying of overlapping memoryview slices with the Intel
+ compiler.
+
- Issue #8413: structsequence now subclasses tuple.
- Issue #8271: during the decoding of an invalid UTF-8 byte sequence, only the
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index e92a771..5b3caf2 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -624,7 +624,7 @@ memory_subscript(PyMemoryViewObject *self, PyObject *key)
static int
memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
{
- Py_ssize_t start, len, bytelen, i;
+ Py_ssize_t start, len, bytelen;
Py_buffer srcview;
Py_buffer *view = &(self->view);
char *srcbuf, *destbuf;
@@ -694,16 +694,8 @@ memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
if (destbuf + bytelen < srcbuf || srcbuf + bytelen < destbuf)
/* No overlapping */
memcpy(destbuf, srcbuf, bytelen);
- else if (destbuf < srcbuf) {
- /* Copy in ascending order */
- for (i = 0; i < bytelen; i++)
- destbuf[i] = srcbuf[i];
- }
- else {
- /* Copy in descencing order */
- for (i = bytelen - 1; i >= 0; i--)
- destbuf[i] = srcbuf[i];
- }
+ else
+ memmove(destbuf, srcbuf, bytelen);
PyBuffer_Release(&srcview);
return 0;