summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_memoryview.py
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2015-01-29 13:29:51 (GMT)
committerStefan Krah <skrah@bytereef.org>2015-01-29 13:29:51 (GMT)
commitf5324d7074d17b026ecd5ef7d7fc16f5e71b0db2 (patch)
tree0b5d602bf7d5372ed54df211b3ebc31b21f59653 /Lib/test/test_memoryview.py
parent6d14405fdb9357b689d76dcfd230018c0ce8c3a8 (diff)
parentfa5d6a5ff3ca247d9c2eaf51853ff39c98c09f4a (diff)
downloadcpython-f5324d7074d17b026ecd5ef7d7fc16f5e71b0db2.zip
cpython-f5324d7074d17b026ecd5ef7d7fc16f5e71b0db2.tar.gz
cpython-f5324d7074d17b026ecd5ef7d7fc16f5e71b0db2.tar.bz2
Closes #22668: Merge from 3.4.
Diffstat (limited to 'Lib/test/test_memoryview.py')
-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.