[Python-checkins] r84408 - in python/branches/py3k: Lib/test/test_memoryview.py Misc/NEWS Objects/memoryobject.c
antoine.pitrou
python-checkins at python.org
Wed Sep 1 23:14:16 CEST 2010
Author: antoine.pitrou
Date: Wed Sep 1 23:14:16 2010
New Revision: 84408
Log:
Issue #9737: Fix a crash when trying to delete a slice or an item from
a memoryview object.
Modified:
python/branches/py3k/Lib/test/test_memoryview.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Objects/memoryobject.c
Modified: python/branches/py3k/Lib/test/test_memoryview.py
==============================================================================
--- python/branches/py3k/Lib/test/test_memoryview.py (original)
+++ python/branches/py3k/Lib/test/test_memoryview.py Wed Sep 1 23:14:16 2010
@@ -111,6 +111,15 @@
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))
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Wed Sep 1 23:14:16 2010
@@ -12,6 +12,9 @@
Core and Builtins
-----------------
+- Issue #9737: Fix a crash when trying to delete a slice or an item from
+ a memoryview object.
+
- Issue #9549: sys.setdefaultencoding() and PyUnicode_SetDefaultEncoding()
are now removed, since their effect was inexistent in 3.x (the default
encoding is hardcoded to utf-8 and cannot be changed).
Modified: python/branches/py3k/Objects/memoryobject.c
==============================================================================
--- python/branches/py3k/Objects/memoryobject.c (original)
+++ python/branches/py3k/Objects/memoryobject.c Wed Sep 1 23:14:16 2010
@@ -631,6 +631,11 @@
"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;
More information about the Python-checkins
mailing list