mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #22668: Ensure that format strings survive slicing after casting.
This commit is contained in:
parent
2934262fd3
commit
fa5d6a5ff3
3 changed files with 73 additions and 6 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue