Skip to content

Commit 9cf85f1

Browse files
committed
Merged revisions 84408-84409 via svnmerge from
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 ........
1 parent 54f824f commit 9cf85f1

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

Lib/test/test_memoryview.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ def setitem(key, value):
117117
m = None
118118
self.assertEquals(sys.getrefcount(b), oldrefcount)
119119

120+
def test_delitem(self):
121+
for tp in self._types:
122+
b = tp(self._source)
123+
m = self._view(b)
124+
with self.assertRaises(TypeError):
125+
del m[1]
126+
with self.assertRaises(TypeError):
127+
del m[1:4]
128+
120129
def test_tobytes(self):
121130
for tp in self._types:
122131
m = self._view(tp(self._source))

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 2.7.1?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #9737: Fix a crash when trying to delete a slice or an item from
16+
a memoryview object.
17+
1518
- Restore GIL in nis_cat in case of error.
1619

1720
- Issue #9688: __basicsize__ and __itemsize__ must be accessed as Py_ssize_t.

Objects/memoryobject.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ _indirect_copy_nd(char *dest, Py_buffer *view, char fort)
179179
int k;
180180
Py_ssize_t elements;
181181
char *ptr;
182-
void (*func)(int, Py_ssize_t *, Py_ssize_t *);
182+
void (*func)(int, Py_ssize_t *, const Py_ssize_t *);
183183

184184
if (view->ndim > PY_SSIZE_T_MAX / sizeof(Py_ssize_t)) {
185185
PyErr_NoMemory();
@@ -639,6 +639,11 @@ memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
639639
"cannot modify read-only memory");
640640
return -1;
641641
}
642+
if (value == NULL) {
643+
PyErr_SetString(PyExc_TypeError,
644+
"cannot delete memory");
645+
return -1;
646+
}
642647
if (view->ndim != 1) {
643648
PyErr_SetNone(PyExc_NotImplementedError);
644649
return -1;

0 commit comments

Comments
 (0)