diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-18 18:57:52 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-18 18:57:52 (GMT) |
commit | ad62b03949eca11677fd55df2f8d5f7ef5f504e8 (patch) | |
tree | 551fbc324e700f5cb526e2a31c8a5540015aa1a1 /Lib/test/test_memoryview.py | |
parent | c8a16867f69c1a28ee6804bb71d67ac5d82fe4d8 (diff) | |
download | cpython-ad62b03949eca11677fd55df2f8d5f7ef5f504e8.zip cpython-ad62b03949eca11677fd55df2f8d5f7ef5f504e8.tar.gz cpython-ad62b03949eca11677fd55df2f8d5f7ef5f504e8.tar.bz2 |
Issue #10451: memoryview objects could allow to mutate a readable buffer.
Initial patch by Ross Lagerwall.
Diffstat (limited to 'Lib/test/test_memoryview.py')
-rw-r--r-- | Lib/test/test_memoryview.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py index 9a52fe90..0bfddd9 100644 --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -9,6 +9,7 @@ import sys import gc import weakref import array +import io class AbstractMemoryTests: @@ -271,6 +272,17 @@ class AbstractMemoryTests: m.release() self._check_released(m, tp) + def test_writable_readonly(self): + # Issue #10451: memoryview incorrectly exposes a readonly + # buffer as writable causing a segfault if using mmap + tp = self.ro_type + if tp is None: + return + b = tp(self._source) + m = self._view(b) + i = io.BytesIO(b'ZZZZ') + self.assertRaises(TypeError, i.readinto, m) + # Variations on source objects for the buffer: bytes-like objects, then arrays # with itemsize > 1. # NOTE: support for multi-dimensional objects is unimplemented. |