Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0c8635

Browse files
committed
Merged revisions 88735 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ........ r88735 | eli.bendersky | 2011-03-04 06:55:25 +0200 (Fri, 04 Mar 2011) | 2 lines Issue #11386: Fixed the exception thrown by bytearray.pop() for empty bytearrays ........
1 parent 752b950 commit e0c8635

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

Lib/test/test_bytes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def test_pop(self):
755755
self.assertEqual(b.pop(0), ord('w'))
756756
self.assertEqual(b.pop(-2), ord('r'))
757757
self.assertRaises(IndexError, lambda: b.pop(10))
758-
self.assertRaises(OverflowError, lambda: bytearray().pop())
758+
self.assertRaises(IndexError, lambda: bytearray().pop())
759759
# test for issue #6846
760760
self.assertEqual(bytearray(b'\xff').pop(), 0xff)
761761

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Core and Builtins
2525

2626
- Check for NULL result in PyType_FromSpec.
2727

28+
- Issue #11386: bytearray.pop() now throws IndexError when the bytearray is
29+
empty, instead of OverflowError.
30+
2831
Library
2932
-------
3033

Objects/bytearrayobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,8 +2285,8 @@ bytearray_pop(PyByteArrayObject *self, PyObject *args)
22852285
return NULL;
22862286

22872287
if (n == 0) {
2288-
PyErr_SetString(PyExc_OverflowError,
2289-
"cannot pop an empty bytearray");
2288+
PyErr_SetString(PyExc_IndexError,
2289+
"pop from empty bytearray");
22902290
return NULL;
22912291
}
22922292
if (where < 0)

0 commit comments

Comments
 (0)