diff options
author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2019-09-09 21:28:34 +0500 |
---|---|---|
committer | T. Wouters <thomas@python.org> | 2019-09-09 09:28:34 -0700 |
commit | 92709a263e9cec0bc646ccc1ea051fc528800d8d (patch) | |
tree | 50dfa3690e7112d46de23e0f372f4c427304774d /Lib/test/test_bytes.py | |
parent | 915cd3f0696cb8a7206754a8fc34d4cd865a1b4a (diff) | |
download | cpython-git-92709a263e9cec0bc646ccc1ea051fc528800d8d.tar.gz |
bpo-37840: Fix handling of negative indices in bytearray_getitem() (GH-15250)
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index b5eeb2b4fc..ddcf367f38 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -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 |