changeset 68223:d2b5bde5c1fa

Issue #11386: Fixed the exception thrown by bytearray.pop() for empty bytearrays
author Eli Bendersky <eliben@gmail.com>
date Fri, 04 Mar 2011 04:55:25 +0000
parents 2f5f755b2687
children 3f70c54d86d8
files Lib/test/test_bytes.py Misc/NEWS Objects/bytearrayobject.c
diffstat 3 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/test/test_bytes.py	Thu Mar 03 18:34:06 2011 +0000
+++ b/Lib/test/test_bytes.py	Fri Mar 04 04:55:25 2011 +0000
@@ -790,7 +790,7 @@
         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)
 
--- a/Misc/NEWS	Thu Mar 03 18:34:06 2011 +0000
+++ b/Misc/NEWS	Fri Mar 04 04:55:25 2011 +0000
@@ -49,6 +49,9 @@
 
 - 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
 -------
 
--- a/Objects/bytearrayobject.c	Thu Mar 03 18:34:06 2011 +0000
+++ b/Objects/bytearrayobject.c	Fri Mar 04 04:55:25 2011 +0000
@@ -2309,8 +2309,8 @@
         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)