]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 84408-84409 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 1 Sep 2010 21:16:10 +0000 (21:16 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 1 Sep 2010 21:16:10 +0000 (21:16 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84408 | antoine.pitrou | 2010-09-01 23:14:16 +0200 (mer., 01 sept. 2010) | 4 lines

  Issue #9737: Fix a crash when trying to delete a slice or an item from
  a memoryview object.
........
  r84409 | antoine.pitrou | 2010-09-01 23:14:46 +0200 (mer., 01 sept. 2010) | 3 lines

  Fix a compilation warning
........

Lib/test/test_memoryview.py
Misc/NEWS
Objects/memoryobject.c

index abda678f7d59091de410abaea441e9672f162cf6..3f8230743f25315a554d06316d2e11ba7434d4d6 100644 (file)
@@ -111,6 +111,15 @@ class AbstractMemoryTests:
         m = None
         self.assertEquals(sys.getrefcount(b), oldrefcount)
 
+    def test_delitem(self):
+        for tp in self._types:
+            b = tp(self._source)
+            m = self._view(b)
+            with self.assertRaises(TypeError):
+                del m[1]
+            with self.assertRaises(TypeError):
+                del m[1:4]
+
     def test_tobytes(self):
         for tp in self._types:
             m = self._view(tp(self._source))
index 4086378017cdf3b371daf6b4c7de88ec20800223..e342ee837d387b219065b6f65c67b2a7e83b57b2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.1.3?
 Core and Builtins
 -----------------
 
+- Issue #9737: Fix a crash when trying to delete a slice or an item from
+  a memoryview object.
+
 - Issue #7415: PyUnicode_FromEncodedObject() now uses the new buffer API
   properly.  Patch by Stefan Behnel.
 
index d09c268e5910691fa51c12c980d61dd3be6d9893..f5dacb04f20d0fa5ce20843d93b9538c47a2328a 100644 (file)
@@ -179,7 +179,7 @@ _indirect_copy_nd(char *dest, Py_buffer *view, char fort)
     int k;
     Py_ssize_t elements;
     char *ptr;
-    void (*func)(int, Py_ssize_t *, Py_ssize_t *);
+    void (*func)(int, Py_ssize_t *, const Py_ssize_t *);
 
     if (view->ndim > PY_SSIZE_T_MAX / sizeof(Py_ssize_t)) {
         PyErr_NoMemory();
@@ -631,6 +631,11 @@ memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
             "cannot modify read-only memory");
         return -1;
     }
+    if (value == NULL) {
+        PyErr_SetString(PyExc_TypeError,
+                        "cannot delete memory");
+        return -1;
+    }
     if (view->ndim != 1) {
         PyErr_SetNone(PyExc_NotImplementedError);
         return -1;