mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-129107: fix thread safety of bytearray
where two critical sections are needed (#130227)
This commit is contained in:
parent
8ba0d7bbc2
commit
e85f81f430
3 changed files with 33 additions and 6 deletions
|
@ -2380,12 +2380,22 @@ class FreeThreadingTest(unittest.TestCase):
|
|||
b.wait()
|
||||
a[:] = c
|
||||
|
||||
def ass_subscript2(b, a, c): # MODIFIES!
|
||||
b.wait()
|
||||
a[:] = c
|
||||
assert b'\xdd' not in a
|
||||
|
||||
def mod(b, a):
|
||||
c = tuple(range(4096))
|
||||
b.wait()
|
||||
try: a % c
|
||||
except TypeError: pass
|
||||
|
||||
def mod2(b, a, c):
|
||||
b.wait()
|
||||
d = a % c
|
||||
assert b'\xdd' not in d
|
||||
|
||||
def repr_(b, a):
|
||||
b.wait()
|
||||
repr(a)
|
||||
|
@ -2503,7 +2513,9 @@ class FreeThreadingTest(unittest.TestCase):
|
|||
|
||||
check([clear] + [contains] * 10)
|
||||
check([clear] + [subscript] * 10)
|
||||
check([clear2] + [ass_subscript2] * 10, None, bytearray(b'0' * 0x400000))
|
||||
check([clear] + [mod] * 10, bytearray(b'%d' * 4096))
|
||||
check([clear2] + [mod2] * 10, bytearray(b'%s'), bytearray(b'0' * 0x400000))
|
||||
|
||||
check([clear] + [capitalize] * 10, bytearray(b'a' * 0x40000))
|
||||
check([clear] + [center] * 10, bytearray(b'a' * 0x40000))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue