Skip to content

Commit e2e58dd

Browse files
author
mark.dickinson
committed
Merged revisions 74675 via svnmerge from
svn+ssh://[email protected]/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://[email protected]/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. ........ ................ git-svn-id: http://svn.python.org/projects/python/branches/release31-maint@74676 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent c63a100 commit e2e58dd

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/test/test_bytes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,8 @@ def test_pop(self):
716716
self.assertEqual(b.pop(-2), ord('r'))
717717
self.assertRaises(IndexError, lambda: b.pop(10))
718718
self.assertRaises(OverflowError, lambda: bytearray().pop())
719+
# test for issue #6846
720+
self.assertEqual(bytearray(b'\xff').pop(), 0xff)
719721

720722
def test_nosort(self):
721723
self.assertRaises(AttributeError, lambda: bytearray().sort())

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's New in Python 3.1.1?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #6846: Fix bug where bytearray.pop() returns negative integers.
16+
1517
- Issue #6750: A text file opened with io.open() could duplicate its output
1618
when writing from multiple threads at the same time.
1719

Objects/bytearrayobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,7 @@ bytearray_pop(PyByteArrayObject *self, PyObject *args)
27052705
if (PyByteArray_Resize((PyObject *)self, n - 1) < 0)
27062706
return NULL;
27072707

2708-
return PyLong_FromLong(value);
2708+
return PyLong_FromLong((unsigned char)value);
27092709
}
27102710

27112711
PyDoc_STRVAR(remove__doc__,

0 commit comments

Comments
 (0)