mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
Issue #11386: Fixed the exception thrown by bytearray.pop() for empty bytearrays
This commit is contained in:
parent
424298a155
commit
1bc4f193d8
3 changed files with 6 additions and 3 deletions
|
@ -790,7 +790,7 @@ class ByteArrayTest(BaseBytesTest):
|
|||
self.assertEqual(b.pop(0), ord('w'))
|
||||
self.assertEqual(b.pop(-2), ord('r'))
|
||||
self.assertRaises(IndexError, lambda: b.pop(10))
|
||||
self.assertRaises(OverflowError, lambda: bytearray().pop())
|
||||
self.assertRaises(IndexError, lambda: bytearray().pop())
|
||||
# test for issue #6846
|
||||
self.assertEqual(bytearray(b'\xff').pop(), 0xff)
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ Core and Builtins
|
|||
|
||||
- Issue #10516: New copy() and clear() methods for lists and bytearrays.
|
||||
|
||||
- Issue #11386: bytearray.pop() now throws IndexError when the bytearray is
|
||||
empty, instead of OverflowError.
|
||||
|
||||
Library
|
||||
-------
|
||||
|
||||
|
|
|
@ -2309,8 +2309,8 @@ bytearray_pop(PyByteArrayObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
if (n == 0) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"cannot pop an empty bytearray");
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"pop from empty bytearray");
|
||||
return NULL;
|
||||
}
|
||||
if (where < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue