]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-129559: add `bytearray.resize` thread safety test for free-threading (GH...
authorCody Maloney <cmaloney@users.noreply.github.com>
Sat, 22 Nov 2025 04:11:20 +0000 (20:11 -0800)
committerGitHub <noreply@github.com>
Sat, 22 Nov 2025 04:11:20 +0000 (09:41 +0530)
[3.14] gh-129559: add `bytearray.resize` thread safety test for free-threading  (GH-141739)
(cherry picked from commit 019c315a8e52978da67a3108e441ed5ee376f504)

Lib/test/test_bytes.py

index 08119f5f7697112c804b8a19b2a442d1f1d67771..1257715586913c337c7087da67924ade3fbe6815 100644 (file)
@@ -2564,6 +2564,10 @@ class FreeThreadingTest(unittest.TestCase):
             c = a.zfill(0x400000)
             assert not c or c[-1] not in (0xdd, 0xcd)
 
+        def resize(b, a):  # MODIFIES!
+            b.wait()
+            a.resize(10)
+
         def check(funcs, a=None, *args):
             if a is None:
                 a = bytearray(b'0' * 0x400000)
@@ -2625,6 +2629,8 @@ class FreeThreadingTest(unittest.TestCase):
         check([clear] + [startswith] * 10)
         check([clear] + [strip] * 10)
 
+        check([clear] + [resize] * 10)
+
         check([clear] + [contains] * 10)
         check([clear] + [subscript] * 10)
         check([clear2] + [ass_subscript2] * 10, None, bytearray(b'0' * 0x400000))