mirror of https://github.com/python/cpython
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 ........
This commit is contained in:
parent
1a33790682
commit
680e6eb54f
|
@ -695,7 +695,7 @@ class ByteArrayTest(BaseBytesTest):
|
||||||
self.assertEqual(b.pop(0), ord('w'))
|
self.assertEqual(b.pop(0), ord('w'))
|
||||||
self.assertEqual(b.pop(-2), ord('r'))
|
self.assertEqual(b.pop(-2), ord('r'))
|
||||||
self.assertRaises(IndexError, lambda: b.pop(10))
|
self.assertRaises(IndexError, lambda: b.pop(10))
|
||||||
self.assertRaises(OverflowError, lambda: bytearray().pop())
|
self.assertRaises(IndexError, lambda: bytearray().pop())
|
||||||
# test for issue #6846
|
# test for issue #6846
|
||||||
self.assertEqual(bytearray(b'\xff').pop(), 0xff)
|
self.assertEqual(bytearray(b'\xff').pop(), 0xff)
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ Core and Builtins
|
||||||
float.__divmod__ with respect to signed zeros. -4.0 % 4.0 should be
|
float.__divmod__ with respect to signed zeros. -4.0 % 4.0 should be
|
||||||
0.0, not -0.0.
|
0.0, not -0.0.
|
||||||
|
|
||||||
|
- Issue #11386: bytearray.pop() now throws IndexError when the bytearray is
|
||||||
|
empty, instead of OverflowError.
|
||||||
|
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
@ -2355,8 +2355,8 @@ bytearray_pop(PyByteArrayObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_IndexError,
|
||||||
"cannot pop an empty bytearray");
|
"pop from empty bytearray");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (where < 0)
|
if (where < 0)
|
||||||
|
|
Loading…
Reference in New Issue