summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_array.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2009-07-05 05:38:18 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2009-07-05 05:38:18 (GMT)
commit7e4f3215db36f6c30cddd0ff160cc05dd26dcefc (patch)
tree04d59f633e6b0f093051903ba4d96af46f313457 /Lib/test/test_array.py
parent200cfd00abd31d40d3f9c4d61ec06b63f3f66170 (diff)
downloadcpython-7e4f3215db36f6c30cddd0ff160cc05dd26dcefc.zip
cpython-7e4f3215db36f6c30cddd0ff160cc05dd26dcefc.tar.gz
cpython-7e4f3215db36f6c30cddd0ff160cc05dd26dcefc.tar.bz2
Issue 4509: Do not modify an array if we know the change would result
in a failure due to exported buffers.
Diffstat (limited to 'Lib/test/test_array.py')
-rwxr-xr-xLib/test/test_array.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 7ae34a9..eb1fffb 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -749,9 +749,25 @@ class BaseTest(unittest.TestCase):
ArraySubclassWithKwargs('b', newarg=1)
def test_create_from_bytes(self):
+ # XXX This test probably needs to be moved in a subclass or
+ # generalized to use self.typecode.
a = array.array('H', b"1234")
self.assertEqual(len(a) * a.itemsize, 4)
+ def test_memoryview_no_resize(self):
+ # Test for issue 4509.
+ a = array.array(self.typecode, self.example)
+ m = memoryview(a)
+ expected = m.tobytes()
+ self.assertRaises(BufferError, a.pop, 0)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.remove, a[0])
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.__setitem__, slice(0, 0), a)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.__delitem__, slice(0, len(a)))
+ self.assertEqual(m.tobytes(), expected)
+
class StringTest(BaseTest):