]> granicus.if.org Git - python/commitdiff
Merged revisions 88735 via svnmerge from
authorEli Bendersky <eliben@gmail.com>
Fri, 4 Mar 2011 06:14:56 +0000 (06:14 +0000)
committerEli Bendersky <eliben@gmail.com>
Fri, 4 Mar 2011 06:14:56 +0000 (06:14 +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 6b5ef3651228ac871c04b5c588f36e13c525dd3d..2026cdbde194e51338e99716723b8e0e8d248226 100644 (file)
@@ -695,7 +695,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 bed3edcfa2999c27c3304e14e2aa9e9270a7ea6f..f1da92c1039ab10ff43e98a1711941d572eb80cb 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -34,6 +34,9 @@ Core and Builtins
   float.__divmod__ with respect to signed zeros.  -4.0 % 4.0 should be
   0.0, not -0.0.
 
+- Issue #11386: bytearray.pop() now throws IndexError when the bytearray is
+  empty, instead of OverflowError.
+
 Library
 -------
 
index 54ef3e7eab914112518abed088f18f374830999c..86093955d8b30b5d21c0134040bf5685a79894e6 100644 (file)
@@ -2355,8 +2355,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)