mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
bpo-37840: Fix handling of negative indices in bytearray_getitem() (GH-15250)
This commit is contained in:
parent
915cd3f069
commit
92709a263e
4 changed files with 24 additions and 2 deletions
|
@ -962,6 +962,15 @@ class BaseBytesTest:
|
|||
c = b.translate(None, delete=b'e')
|
||||
self.assertEqual(c, b'hllo')
|
||||
|
||||
def test_sq_item(self):
|
||||
_testcapi = test.support.import_module('_testcapi')
|
||||
obj = self.type2test((42,))
|
||||
with self.assertRaises(IndexError):
|
||||
_testcapi.sequence_getitem(obj, -2)
|
||||
with self.assertRaises(IndexError):
|
||||
_testcapi.sequence_getitem(obj, 1)
|
||||
self.assertEqual(_testcapi.sequence_getitem(obj, 0), 42)
|
||||
|
||||
|
||||
class BytesTest(BaseBytesTest, unittest.TestCase):
|
||||
type2test = bytes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue