Skip to content

Commit 8ded082

Browse files
committed
Address review: frame test around concurrent mutation, drop benign control
1 parent e70a1e8 commit 8ded082

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

Lib/test/test_bytes.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,9 @@ def test_join(self):
645645
with self.assertRaises(TypeError):
646646
dot_join([memoryview(b"ab"), "cd", b"ef"])
647647

648-
def test_join_reentrant_buffer_mutation(self):
649-
# An item's __buffer__() may run Python that drops the last reference
650-
# to that item by mutating the joined sequence.
648+
def test_join_concurrent_buffer_mutation(self):
649+
# __buffer__() can release the GIL, letting another thread concurrently
650+
# mutate the joined sequence (simulated here by mutating in __buffer__).
651651
# See: https://github.com/python/cpython/issues/151295
652652
def make_seq(mutate):
653653
# Item is only referenced from the list slot, so mutate() frees it.
@@ -658,10 +658,6 @@ def __buffer__(self, flags):
658658
seq = [b'a', Item(), b'c']
659659
return seq
660660

661-
class Benign:
662-
def __buffer__(self, flags):
663-
return memoryview(b'x')
664-
665661
for sep in (self.type2test(b''), self.type2test(b'::')):
666662
with self.subTest(sep=sep):
667663
# Changing the list length is reported as a RuntimeError.
@@ -675,10 +671,6 @@ def replace(seq):
675671
seq = make_seq(replace)
676672
self.assertEqual(sep.join(seq), sep.join([b'a', b'x', b'c']))
677673

678-
# A benign __buffer__() that does not mutate joins normally.
679-
self.assertEqual(sep.join([Benign(), b'Y', Benign()]),
680-
sep.join([b'x', b'Y', b'x']))
681-
682674
def test_count(self):
683675
b = self.type2test(b'mississippi')
684676
i = 105

0 commit comments

Comments
 (0)