Commit 1bc4f193 authored by Eli Bendersky's avatar Eli Bendersky

Issue #11386: Fixed the exception thrown by bytearray.pop() for empty bytearrays

parent 424298a1
...@@ -790,7 +790,7 @@ class ByteArrayTest(BaseBytesTest): ...@@ -790,7 +790,7 @@ class ByteArrayTest(BaseBytesTest):
self.assertEqual(b.pop(0), ord('w')) self.assertEqual(b.pop(0), ord('w'))
self.assertEqual(b.pop(-2), ord('r')) self.assertEqual(b.pop(-2), ord('r'))
self.assertRaises(IndexError, lambda: b.pop(10)) self.assertRaises(IndexError, lambda: b.pop(10))
self.assertRaises(OverflowError, lambda: bytearray().pop()) self.assertRaises(IndexError, lambda: bytearray().pop())
# test for issue #6846 # test for issue #6846
self.assertEqual(bytearray(b'\xff').pop(), 0xff) self.assertEqual(bytearray(b'\xff').pop(), 0xff)
......
...@@ -49,6 +49,9 @@ Core and Builtins ...@@ -49,6 +49,9 @@ Core and Builtins
- Issue #10516: New copy() and clear() methods for lists and bytearrays. - 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 Library
------- -------
......
...@@ -2309,8 +2309,8 @@ bytearray_pop(PyByteArrayObject *self, PyObject *args) ...@@ -2309,8 +2309,8 @@ bytearray_pop(PyByteArrayObject *self, PyObject *args)
return NULL; return NULL;
if (n == 0) { if (n == 0) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_IndexError,
"cannot pop an empty bytearray"); "pop from empty bytearray");
return NULL; return NULL;
} }
if (where < 0) if (where < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment