summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_memoryview.py19
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.