Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f43f65b

Browse files
committed
Merged revisions 84408-84409 via svnmerge from
svn+ssh://[email protected]/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 38164c3 commit f43f65b

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
@@ -111,6 +111,15 @@ def setitem(key, value):
111111
m = None
112112
self.assertEquals(sys.getrefcount(b), oldrefcount)
113113

114+
def test_delitem(self):
115+
for tp in self._types:
116+
b = tp(self._source)
117+
m = self._view(b)
118+
with self.assertRaises(TypeError):
119+
del m[1]
120+
with self.assertRaises(TypeError):
121+
del m[1:4]
122+
114123
def test_tobytes(self):
115124
for tp in self._types:
116125
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 3.1.3?
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
- Issue #7415: PyUnicode_FromEncodedObject() now uses the new buffer API
1619
properly. Patch by Stefan Behnel.
1720

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();
@@ -631,6 +631,11 @@ memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
631631
"cannot modify read-only memory");
632632
return -1;
633633
}
634+
if (value == NULL) {
635+
PyErr_SetString(PyExc_TypeError,
636+
"cannot delete memory");
637+
return -1;
638+
}
634639
if (view->ndim != 1) {
635640
PyErr_SetNone(PyExc_NotImplementedError);
636641
return -1;

0 commit comments

Comments
 (0)