summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_bytes.py2
-rw-r--r--Misc/NEWS2
-rw-r--r--Objects/bytearrayobject.c2
3 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 00aee02..48b0258 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -691,6 +691,8 @@ class ByteArrayTest(BaseBytesTest):
self.assertEqual(b.pop(-2), ord('r'))
self.assertRaises(IndexError, lambda: b.pop(10))
self.assertRaises(OverflowError, lambda: bytearray().pop())
+ # test for issue #6846
+ self.assertEqual(bytearray(b'\xff').pop(), 0xff)
def test_nosort(self):
self.assertRaises(AttributeError, lambda: bytearray().sort())
diff --git a/Misc/NEWS b/Misc/NEWS
index aed5bf8..afaa55b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.6.3
Core and Builtins
-----------------
+- Issue #6846: Fix bug where bytearray.pop() returns negative integers.
+
- Issue #6707: dir() on an uninitialized module caused a crash.
- Issue #6540: Fixed crash for bytearray.translate() with invalid parameters.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 7eafce7..f6a5c16 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2758,7 +2758,7 @@ bytes_pop(PyByteArrayObject *self, PyObject *args)
if (PyByteArray_Resize((PyObject *)self, n - 1) < 0)
return NULL;
- return PyInt_FromLong(value);
+ return PyInt_FromLong((unsigned char)value);
}
PyDoc_STRVAR(remove__doc__,