Merged revisions 88735 via svnmerge from
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
........
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index e5c7ccd..9be1008 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -755,7 +755,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)
 
diff --git a/Misc/NEWS b/Misc/NEWS
index 1e2a14f..fcbcc88 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,9 @@
 
 - Check for NULL result in PyType_FromSpec.
 
+- Issue #11386: bytearray.pop() now throws IndexError when the bytearray is
+  empty, instead of OverflowError.
+
 Library
 -------
 
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 7448354..aefec94 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2285,8 +2285,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)