mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.14] gh-140260: fix data race in _struct module initialization with subinterpreters (GH-140909) (#141501)
gh-140260: fix data race in `_struct` module initialization with subinterpreters (GH-140909)
(cherry picked from commit 63548b3699)
Co-authored-by: Shamil <ashm.tech@proton.me>
This commit is contained in:
parent
7e9400c3e6
commit
79195df23c
4 changed files with 70 additions and 41 deletions
|
|
@ -800,6 +800,23 @@ def test_c_complex_round_trip(self):
|
|||
round_trip = struct.unpack(f, struct.pack(f, z))[0]
|
||||
self.assertComplexesAreIdentical(z, round_trip)
|
||||
|
||||
@unittest.skipIf(
|
||||
support.is_android or support.is_apple_mobile,
|
||||
"Subinterpreters are not supported on Android and iOS"
|
||||
)
|
||||
def test_endian_table_init_subinterpreters(self):
|
||||
# Verify that the _struct extension module can be initialized
|
||||
# concurrently in subinterpreters (gh-140260).
|
||||
try:
|
||||
from concurrent.futures import InterpreterPoolExecutor
|
||||
except ImportError:
|
||||
raise unittest.SkipTest("InterpreterPoolExecutor not available")
|
||||
|
||||
code = "import struct"
|
||||
with InterpreterPoolExecutor(max_workers=5) as executor:
|
||||
results = executor.map(exec, [code] * 5)
|
||||
self.assertListEqual(list(results), [None] * 5)
|
||||
|
||||
|
||||
class UnpackIteratorTest(unittest.TestCase):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue