cpython/Tools
T. Wouters 388e1ca9f0
gh-115999: Make list and tuple iteration more thread-safe. (#128637)
Make tuple iteration more thread-safe, and actually test concurrent iteration of tuple, range and list. (This is prep work for enabling specialization of FOR_ITER in free-threaded builds.) The basic premise is:

Iterating over a shared iterable (list, tuple or range) should be safe, not involve data races, and behave like iteration normally does.

Using a shared iterator should not crash or involve data races, and should only produce items regular iteration would produce. It is not guaranteed to produce all items, or produce each item only once. (This is not the case for range iteration even after this PR.)

Providing stronger guarantees is possible for some of these iterators, but it's not always straight-forward and can significantly hamper the common case. Since iterators in general aren't shared between threads, and it's simply impossible to concurrently use many iterators (like generators), better to make sharing iterators without explicit synchronization clearly wrong.

Specific issues fixed in order to make the tests pass:

 - List iteration could occasionally fail an assertion when a shared list was shrunk and an item past the new end was retrieved concurrently. There's still some unsafety when deleting/inserting multiple items through for example slice assignment, which uses memmove/memcpy.

 - Tuple iteration could occasionally crash when the iterator's reference to the tuple was cleared on exhaustion. Like with list iteration, in free-threaded builds we can't safely and efficiently clear the iterator's reference to the iterable (doing it safely would mean extra, slow refcount operations), so just keep the iterable reference around.
2025-02-18 16:52:46 -08:00
..
build GH-107956: install build-details.json (PEP 739) (#130069) 2025-02-13 13:58:00 +00:00
buildbot gh-115556: Remove quotes from command-line arguments in test.bat and rt.bat (#115557) 2024-02-16 21:24:56 +01:00
c-analyzer gh-128130: Fix unhandled keyboard interrupt data race (gh-129975) 2025-02-13 12:29:03 -05:00
cases_generator gh-129989: Change Py_TAIL_CALL_INTERP ifndef to ! (#130269) 2025-02-18 15:48:49 +00:00
clinic Replace strict_concatenate = True with extra_checks = True (#126391) 2025-01-25 12:44:23 +03:00
freeze gh-65701: document that freeze doesn't work with framework builds on macOS (#113352) 2023-12-21 16:28:00 +01:00
ftscalingbench gh-125985: Fix cmodule_function() scaling benchmark (#128460) 2025-01-03 21:48:47 +00:00
gdb gh-127119: Faster check for small ints in long_dealloc (GH-127620) 2025-01-29 15:22:18 +00:00
i18n gh-44827: Improve error if BOM on first line of .po file (GH-130187) 2025-02-18 15:59:34 +02:00
importbench gh-58032: Do not use argparse.FileType in module CLIs and scripts (GH-113649) 2024-01-10 15:07:19 +02:00
jit gh-129805: Fix bytes annotation in Tools/jit (#129806) 2025-02-17 10:55:30 +03:00
lockbench
msi gh-125729: Makes the installation of the turtle module dependent on the Tcl/Tk install option (GH-126176) 2024-11-19 17:19:33 +00:00
nuget
patchcheck GH-109408: Stop running patchcheck in CI (#109895) 2024-08-03 12:52:21 +01:00
peg_generator gh-125588: Allow to regenerate the parser with Python < 3.12 (#127969) 2024-12-15 23:17:01 +00:00
scripts GH-129715: Remove _DYNAMIC_EXIT (GH-129716) 2025-02-07 11:41:17 -08:00
ssl gh-127330: Update for OpenSSL 3.4 & document+improve the update process (GH-127331) 2024-11-28 13:29:27 +01:00
tsan gh-115999: Make list and tuple iteration more thread-safe. (#128637) 2025-02-18 16:52:46 -08:00
tz
unicode gh-126525: Fix makeunicodedata.py output on macOS and Windows (#126526) 2024-11-12 13:23:57 +03:00
unittestgui
wasm Emscripten: use better _Py_Version computation for worker module (#129757) 2025-02-07 12:55:27 +08:00
README gh-100176: Remove outdated Tools/{io,cc,string}bench (#101853) 2024-02-17 14:17:21 -07:00
requirements-dev.txt gh-109413: Add more type hints to libregrtest (#126352) 2024-11-04 13:15:57 +03:00
requirements-hypothesis.txt build(deps): bump hypothesis from 6.108.10 to 6.111.2 in /Tools (#123567) 2024-09-02 08:04:50 +03:00

This directory contains a number of Python programs that are useful
while building or extending Python.

build           Automatically generated directory by the build system
                contain build artifacts and intermediate files.

buildbot        Batchfiles for running on Windows buildbot workers.

c-analyzer      Tools to check no new global variables have been added.

cases_generator Tooling to generate interpreters.

clinic          A preprocessor for CPython C files in order to automate
                the boilerplate involved with writing argument parsing
                code for "builtins".

freeze          Create a stand-alone executable from a Python program.

gdb             Python code to be run inside gdb, to make it easier to
                debug Python itself (by David Malcolm).

i18n            Tools for internationalization. pygettext.py
                parses Python source code and generates .pot files,
                and msgfmt.py generates a binary message catalog
                from a catalog in text format.

importbench     A set of micro-benchmarks for various import scenarios.

msi             Support for packaging Python as an MSI package on Windows.

nuget           Files for the NuGet package manager for .NET.

patchcheck      Tools for checking and applying patches to the Python source code
                and verifying the integrity of patch files.

peg_generator   PEG-based parser generator (pegen) used for new parser.

scripts         A number of useful single-file programs, e.g. run_tests.py
                which runs the Python test suite.

ssl             Scripts to generate ssl_data.h from OpenSSL sources, and run
                tests against multiple installations of OpenSSL and LibreSSL.

tz              A script to dump timezone from /usr/share/zoneinfo.

unicode         Tools for generating unicodedata and codecs from unicode.org
                and other mapping files (by Fredrik Lundh, Marc-Andre Lemburg
                and Martin von Loewis).

unittestgui     A Tkinter based GUI test runner for unittest, with test
                discovery.

wasm            Config and helpers to facilitate cross compilation of CPython
                to WebAssembly (WASM).

Note: The pynche color editor has moved to https://gitlab.com/warsaw/pynche