Files
cpython/Lib/test/test_free_threading/test_exceptions.py
T
Miss Islington (bot) 25eb043eba [3.15] gh-144774: Add critical section in BaseException.__setstate__ (GH-150578) (#153746)
gh-144774: Add critical section in `BaseException.__setstate__` (GH-150578)
(cherry picked from commit f586fd9e30)

Co-authored-by: Brij Kapadia <97006829+brijkapadia@users.noreply.github.com>
2026-07-15 10:44:37 +00:00

17 lines
412 B
Python

import unittest
import copy
from test.support import threading_helper
threading_helper.requires_working_threading(module=True)
class ExceptionTests(unittest.TestCase):
def test_setstate_data_race(self):
E = Exception()
def func():
for i in range(100):
setattr(E, 'x', i)
copy.copy(E)
threading_helper.run_concurrently(func, nthreads=4)