cpython/Lib/test/test_free_threading/test_datetime.py
Miss Islington (bot) d89f40b4c4
[3.15] gh-159458: Fix free-threading data race in datetime strftime century normalization (GH-159520) (gh-159536)
gh-159458: Fix free-threading data race in datetime strftime century normalization (GH-159520)
(cherry picked from commit ddc647a341)

Co-authored-by: Anna <araslanova.anna.a@gmail.com>
2026-10-20 11:57:32 -07:00

25 lines
605 B
Python

import datetime
import unittest
from test.support import threading_helper
from test.support.threading_helper import run_concurrently
NTHREADS = 10
@threading_helper.requires_working_threading()
class TestDatetime(unittest.TestCase):
def test_concurrent_strftime_normalize_century(self):
d = datetime.date(2026, 4, 12)
results = []
def worker():
results.append(d.strftime("%Y-%m-%d"))
run_concurrently(worker_func=worker, nthreads=NTHREADS)
self.assertEqual(results, ["2026-04-12"] * NTHREADS)
if __name__ == "__main__":
unittest.main()