diff options
author | Stefan Krah <skrah@bytereef.org> | 2015-01-29 13:27:23 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2015-01-29 13:27:23 (GMT) |
commit | fa5d6a5ff3ca247d9c2eaf51853ff39c98c09f4a (patch) | |
tree | 1811bdf701fbeb5e9709624ede624d1bbaa9b677 /Lib/test | |
parent | 2934262fd36c35843c01b96657047625ce2e3cf6 (diff) | |
download | cpython-fa5d6a5ff3ca247d9c2eaf51853ff39c98c09f4a.zip cpython-fa5d6a5ff3ca247d9c2eaf51853ff39c98c09f4a.tar.gz cpython-fa5d6a5ff3ca247d9c2eaf51853ff39c98c09f4a.tar.bz2 |
Issue #22668: Ensure that format strings survive slicing after casting.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_memoryview.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py index e7df8a7..bd9d0d4 100644 --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -360,6 +360,25 @@ class AbstractMemoryTests: self.assertEqual(list(reversed(m)), aslist) self.assertEqual(list(reversed(m)), list(m[::-1])) + def test_issue22668(self): + m = memoryview(bytes(range(8))) + b = m.cast('H') + c = b[0:2] + d = memoryview(b) + + del b + + self.assertEqual(c[0], 256) + self.assertEqual(d[0], 256) + self.assertEqual(c.format, "H") + self.assertEqual(d.format, "H") + + _ = m.cast('I') + self.assertEqual(c[0], 256) + self.assertEqual(d[0], 256) + self.assertEqual(c.format, "H") + self.assertEqual(d.format, "H") + # Variations on source objects for the buffer: bytes-like objects, then arrays # with itemsize > 1. |