]> granicus.if.org Git - python/commitdiff
Merged revisions 88735 via svnmerge from
authorEli Bendersky <eliben@gmail.com>
Fri, 4 Mar 2011 05:10:57 +0000 (05:10 +0000)
committerEli Bendersky <eliben@gmail.com>
Fri, 4 Mar 2011 05:10:57 +0000 (05:10 +0000)
svn+ssh://pythondev@svn.python.org/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
........

Lib/test/test_bytes.py
Misc/NEWS
Objects/bytearrayobject.c

index e5c7ccd4ff0aca18418639bd356da4672f88daa7..9be1008c364bb507f4cc417b86b9518c2d7547ac 100644 (file)
@@ -755,7 +755,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)
 
index 1e2a14f438eb9bd1ef36ba4c936584d45d087d93..fcbcc882a97f53e1bf3eef18c5276987f7eb405b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,9 @@ Core and Builtins
 
 - Check for NULL result in PyType_FromSpec.
 
+- Issue #11386: bytearray.pop() now throws IndexError when the bytearray is
+  empty, instead of OverflowError.
+
 Library
 -------
 
index 74483544c0007c073b53ad6d18effc928d0d7194..aefec9425f47f6286a90973d1433ddea465e3221 100644 (file)
@@ -2285,8 +2285,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)