]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-129559: add `bytearray.resize` thread safety test for free-threading (#141739)
authorCody Maloney <cmaloney@users.noreply.github.com>
Fri, 21 Nov 2025 18:12:22 +0000 (10:12 -0800)
committerGitHub <noreply@github.com>
Fri, 21 Nov 2025 18:12:22 +0000 (23:42 +0530)
Lib/test/test_bytes.py

index 7ca38bb8c8421e5be8e7fd14a5a3f608cc79c28c..a6cf899fa51e759632f510903d353181b3100d97 100644 (file)
@@ -2655,6 +2655,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 take_bytes(b, a):  # MODIFIES!
             b.wait()
             c = a.take_bytes()
@@ -2728,6 +2732,8 @@ class FreeThreadingTest(unittest.TestCase):
         check([clear] + [startswith] * 10)
         check([clear] + [strip] * 10)
 
+        check([clear] + [resize] * 10)
+
         check([clear] + [take_bytes] * 10)
         check([take_bytes_n] * 10, bytearray(b'0123456789' * 0x400))
         check([take_bytes_n] * 10, bytearray(b'0123456789' * 5))