Reorganises the large Emscripten-specific file into the Emscripten folder.
(cherry picked from commit bbe589f93c)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
gh-136421: Load `_datetime` static types during interpreter initialization (GH-136583)
`_datetime` is a special module, because it's the only non-builtin C extension that contains static types. As such, it would initialize static types in the module's execution function, which can run concurrently. Since static type initialization is not thread-safe, this caused crashes. This fixes it by moving the initialization of `_datetime`'s static types to interpreter startup (where all other static types are initialized), which is already properly protected through other locks.
(cherry picked from commit a10960699a)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
gh-136870: fix data race in `PyThreadState_Clear` on `sys_tracing_threads` (GH-136951)
In free-threading, multiple threads can be cleared concurrently as such the modifications on `sys_tracing_threads` should be done while holding the profile lock, otherwise it can race with other threads setting up profiling.
(cherry picked from commit f183996eb7)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
GH-136874: `url2pathname()`: discard query and fragment components (GH-136875)
In `urllib.request.url2pathname()`, ignore any query or fragment components
in the given URL.
(cherry picked from commit 80b2d60a51)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Pedantic rewording of why relative importing doesn't work in main modules (GH-136846)
Pedantically reword the section about relative imports and main modules.
(cherry picked from commit 4b68289ca6)
Co-authored-by: Josh Cannon <joshdcannon@gmail.com>
gh-134411: assert `PyLong_FromLong(x) != NULL` when `x` is known to be small (GH-134415)
Since `PyLong_From Long(PY_MONITORING_DEBUGGER_ID)` falls to `small_int` case and can't return `NULL`. Added `assert`s for extra confidence.
https://github.com/python/cpython/issues/134411#issuecomment-2897653868
(cherry picked from commit cf19b6435d)
Co-authored-by: Sergey Muraviov <smurav@mail.ru>
gh-136428: amend UUIDv8 performance improvements (GH-136903)
UUIDv8 has been added in Python 3.14.0a2 and its construction time
has been improved in Python 3.14.0a4, but since those changes will
not be visible when comparing the latest Python 3.13 and 3.14 together,
we do not document them on the What's New page to avoid confusion.
(cherry picked from commit 5798348a07)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472)
The OS thread name is now correctly prefixed with `InterpreterPoolExecutor` instead of `ThreadPoolExecutor`.
(cherry picked from commit 246be21de1)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
GH-130645: Default to color help in argparse (GH-136809)
(cherry picked from commit acbe896cb1)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
gh-86608: Improve and restructure tarfile examples (GH-121771)
Add an example on how to write a tarfile to stdout; general improvements.
(cherry picked from commit cc81b4e501)
Co-authored-by: Dominic H <dom@dominic.sk>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Extend the documentation for disabling pymalloc with the `--without-pymalloc` flag regarding why it is worth to use it when enabling AddressSanitizer for Python build (which is done, e.g., in CPython's CI builds).
I have tested the CPython latest main build with both ASan and pymalloc enabled and it seems to work just fine. I did run the `python -m test` suite which didn't uncover any ASan crashes (though, it detected some memory leaks, which I believe are irrelevant here).
I have discussed ASan and this flag with @encukou on the CPython Core sprint on EuroPython 2025. We initially thought that the `--without-pymalloc` flag is needed for ASan builds due to the fact pymalloc must hit the begining of page when determining if the memory to be freed comes from pymalloc or was allocated by the system malloc. In other words, we thought, that ASan would crash CPython during free of big objects (allocated by system malloc). It may be that this was the case in the past, but it is not the case anymore as the `address_in_range` function used by pymalloc is annotated to be skipped from the ASan instrumentation.
(cherry picked from commit d19bb44713)
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-54732: Make argparse error caused by empty rows in option files explicit (GH-136795)
(cherry picked from commit 8ffc3ef01e)
Co-authored-by: jdunter <2ve@mailbox.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
gh-135730: Clarify multiprocessing.Queue close() documentation (GH-136803)
Add a copy of the text from SimpleQueue.close()
---------
(cherry picked from commit f575588ccf)
Co-authored-by: aggshruti99 <aggshruti99@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-136769: Include fixed-width integers in the fundamental data types table (GH-136784)
Fixed-sized types, like ``c_int32``, are currently missing from the fundamental data types table
in the ``ctypes`` documentation. This commit adds them, and notes that ``c_[u]int8`` is an alias
of ``c_[u]byte``.
(cherry picked from commit acefb978dc)
Co-authored-by: Sina Zel taat <111974143+SZeltaat@users.noreply.github.com>
gh-74598: document that `fnmatch.filterfalse` is affected by cache limitation (GH-136781)
(cherry picked from commit 263e451c41)
Co-authored-by: Gergely Elias <gergely.elias@gmail.com>
Docs: Improve example for ``itertools.batched()`` (GH-136775)
The current example `batched('ABCDEFG', n=3) → ABC DEF G` can confuse readers because both, the size of the tuples and the number of tuples are 3.
By using a batch size of n=2, it is clearer that the `n` argument refers to the size of the resulting tuples.
I.e. the new example is: `batched('ABCDEFG', n=2) → AB CD EF G`
(cherry picked from commit 3eecc72ac7)
Co-authored-by: RafaelWO <38643099+RafaelWO@users.noreply.github.com>
gh-136697: Use the standard audit event format for sys.monitoring docs (GH-136747)
(cherry picked from commit 28937d3a21)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Clears the umask used during a test of pydoc.apropos when testing on
Emscripten. This is to work around a known issue in Emscripten; but it's not
clear if the chmod call that is causing the problem is actually testing
anything of significance.
(cherry picked from commit 22af5d35a6)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
This might have been fixed by gh-136624, or by some Emscripten change.
In any case, it no longer seems to be needed.
(cherry picked from commit dcd27aace1)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Provide a stub implementation of umask that is enough to get some tests passing.
More work is needed upstream in Emscripten to make all umask tests to pass.
(cherry picked from commit 12e52cad71)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Makes the Emscripten stack overflow skip message consistent with WASI,
and replaces some ad-hoc skips.
(cherry picked from commit c730952aa6)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Corrects the handling of getuid on emscripten, which was consistently reporting as 0.
(cherry picked from commit e81c4e84b3)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>