mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Issue #6846: bytearray.pop was returning ints in the range [-128, 128)
instead of [0, 256). Thanks Hagen Fürstenau for the report and fix.
This commit is contained in:
parent
2596758cb4
commit
c8a7c7c3b9
3 changed files with 5 additions and 1 deletions
|
@ -690,6 +690,8 @@ class ByteArrayTest(BaseBytesTest):
|
||||||
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(OverflowError, lambda: bytearray().pop())
|
||||||
|
# test for issue #6846
|
||||||
|
self.assertEqual(bytearray(b'\xff').pop(), 0xff)
|
||||||
|
|
||||||
def test_nosort(self):
|
def test_nosort(self):
|
||||||
self.assertRaises(AttributeError, lambda: bytearray().sort())
|
self.assertRaises(AttributeError, lambda: bytearray().sort())
|
||||||
|
|
|
@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #6846: Fix bug where bytearray.pop() returns negative integers.
|
||||||
|
|
||||||
- classmethod no longer checks if its argument is callable.
|
- classmethod no longer checks if its argument is callable.
|
||||||
|
|
||||||
- Issue #6750: A text file opened with io.open() could duplicate its output
|
- Issue #6750: A text file opened with io.open() could duplicate its output
|
||||||
|
|
|
@ -2773,7 +2773,7 @@ bytearray_pop(PyByteArrayObject *self, PyObject *args)
|
||||||
if (PyByteArray_Resize((PyObject *)self, n - 1) < 0)
|
if (PyByteArray_Resize((PyObject *)self, n - 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyInt_FromLong(value);
|
return PyInt_FromLong((unsigned char)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(remove__doc__,
|
PyDoc_STRVAR(remove__doc__,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue