Skip to content

Commit 5128c85

Browse files
committed
Frame the NEWS as a concurrency issue and add the grow-during-__buffer__ test
1 parent 0bb3bef commit 5128c85

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

Lib/test/test_bytes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,10 @@ def __buffer__(self, flags):
18181818
b = bytearray(b'x' * 100)
18191819
b.extend(Evil(lambda: b.__delitem__(slice(30, None))))
18201820
self.assertEqual(b, b'x' * 30 + b'ABCDEFGH')
1821+
# grow during __buffer__: the data lands at the original end.
1822+
b = bytearray(b'x' * 10)
1823+
b.extend(Evil(lambda: b.extend(b'y' * 100)))
1824+
self.assertEqual(b, b'x' * 10 + b'ABCDEFGH' + b'y' * 100)
18211825

18221826
def test_iconcat(self):
18231827
b = bytearray(b"abc")
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
Fix a crash in :meth:`bytearray.extend` when the argument's
2-
:meth:`~object.__buffer__` method resizes the bytearray. Patch by tonghuaroot.
1+
Fix an out-of-bounds write in :meth:`bytearray.extend` when the bytearray is
2+
resized while the argument's :meth:`~object.__buffer__` is being acquired, for
3+
example by another thread. Patch by tonghuaroot.

0 commit comments

Comments
 (0)