summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-09-06 10:20:23 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-09-06 10:20:23 (GMT)
commit424d75a3f57bfd465dd7c7342f79a8afeaafafcb (patch)
treeb1b4dba85a25d2d7958c6e56509179ee0b921694
parent45b9f370fcfa267782693fc4d441a5b80afd661b (diff)
downloadcpython-424d75a3f57bfd465dd7c7342f79a8afeaafafcb.zip
cpython-424d75a3f57bfd465dd7c7342f79a8afeaafafcb.tar.gz
cpython-424d75a3f57bfd465dd7c7342f79a8afeaafafcb.tar.bz2
Merged revisions 74675 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r74675 | mark.dickinson | 2009-09-06 11:19:23 +0100 (Sun, 06 Sep 2009) | 10 lines Merged revisions 74673 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74673 | mark.dickinson | 2009-09-06 11:03:31 +0100 (Sun, 06 Sep 2009) | 3 lines 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. ........ ................
-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 caea909..dd01b93 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -716,6 +716,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 9b189f5..45201cc 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 3.1.1?
Core and Builtins
-----------------
+- Issue #6846: Fix bug where bytearray.pop() returns negative integers.
+
- Issue #6750: A text file opened with io.open() could duplicate its output
when writing from multiple threads at the same time.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index f3d5697..f8f9469 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2705,7 +2705,7 @@ bytearray_pop(PyByteArrayObject *self, PyObject *args)
if (PyByteArray_Resize((PyObject *)self, n - 1) < 0)
return NULL;
- return PyLong_FromLong(value);
+ return PyLong_FromLong((unsigned char)value);
}
PyDoc_STRVAR(remove__doc__,