[3.14] gh-123471: Free-threading fixes for itertools (GH-131212) (GH-132814) (GH-135689) (GH-144402) (GH-146033) (GH-142957) (GH-153791)
Combined backport of PRs from main branch, fixing free-threading data-races in itertools:
* gh-123471: make concurrent iteration over `itertools.cycle` safe under free-threading (gh-131212)
* gh-123471: Make itertools.product and itertools.combinations thread-safe (GH-132814)
* gh-123471: Make itertools.chain thread-safe (gh-135689)
* gh-123471: Make concurrent iteration over `itertools.permutations` and `itertools.combinations_with_replacement` thread-safe (gh-144402)
* gh-123471: make concurrent iteration over itertools.accumulate thread-safe (gh-144486)
* gh-123471: Make `itertools.zip_longest` safe in the FT build (gh-146033)
(cherry picked from commit
26a1cd4e8c0c9ea1a6683abd82547ddee656ff3d)
(cherry picked from commit
847d1c2cb4014f122df64e0db0b3b554c01779c6)
(cherry picked from commit
0533c1faf27d1e50b062bb623dfad93288757f57)
(cherry picked from commit
009c8c052f5eb9f869c09029724ef194d8c161ca)
(cherry picked from commit
3a248564470075cb8c7b8a75fe7ba61f7ea341b2)
(cherry picked from commit
9214e3f33eeeb0ee862777378f98fdeb7b6944c6)
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>