Fix free-threading scaling bottleneck in sys.intern and `PyObject_SetAttr` by
avoiding the interpreter-wide lock when the string is already interned and
immortalized.
(cherry picked from commit 60093096ba)
(cherry picked from commit c94048be02)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Add special cases for classmethod and staticmethod descriptors in
_PyObject_GetMethodStackRef() to avoid calling tp_descr_get, which
avoids reference count contention on the bound method and underlying
callable. This improves scaling when calling classmethods and
staticmethods from multiple threads.
Also refactor method_vectorcall in classobject.c into a new
_PyObject_VectorcallPrepend() helper so that it can be used by
PyObject_VectorcallMethod as well.
(cherry picked from commit e0f7c1097e)
* Add the c_init_default attribute which is used to initialize the C variable
if the default is not explicitly provided.
* Add the c_default_init() method which is used to derive c_default from
default if c_default is not explicitly provided.
* Explicit c_default and py_default are now almost always have precedence
over the generated value.
* Add support for bytes literals as default values.
* Improve support for str literals as default values (support non-ASCII
and non-printable characters and special characters like backslash or quotes).
* Fix support for str and bytes literals containing trigraphs, "/*" and "*/".
* Improve support for default values in converters "char" and "int(accept={str})".
* Converter "int(accept={str})" now requires 1-character string instead of
integer as default value.
* Add support for non-None default values in converter "Py_buffer": NULL,
str and bytes literals.
* Improve error handling for invalid default values.
* Rename Null to NullType for consistency.
(cherry picked from commit 99e2c5eccd)
Modifies the Emscripten build script to allow for caching of dependencies, and
for automated installation of new EMSDK versions.
(cherry picked from commit ebb150e76a)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Modifies the Emscripten build script to allow for custom cross-build directory
names, and to only clean Emscripten-specific paths (optionally including the
build python).
(cherry picked from commit 015613384f)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Adds an `--emsdk-cache` argument to the Emscripten build script and an
emscripten_version.txt file. If the `--emsdk-cache` argument is passed, the build script
will look in `emscripten_version.txt` to get the expected emsdk version is installed in
a folder called e.g., 4.0.12 in the directory indicated by the `--emsdk-cache` argument,
and run the build with that Emscripten tooling activated.
(cherry picked from commit c3fb0d9d96)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
[3.14] gh-144551: Update CI to use latest OpenSSL versions
Also update _ssl_data_35.h to include an added symbol from 3.5.5.
(cherry picked from commit b933ef9261)
The behaviour of Cut in nested parentheses, Repeat, Opt, and similar
is somewhat chaotic. Apparently even the academic papers on PEG aren't
as clear as they could be.
And it doesn't really matter. Python only uses top-level cuts.
When that changes, we can clarify as much as necessary (and even
change the implementation to make sense for what we'll need).
Document that this is deliberately unspecified, and add a test to
make sure any decision is deliberate, tested and documented.
(cherry picked from commit f0a0467c17)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-141004: Document several soft-deprecated C APIs (GH-141634)
(cherry picked from commit 0e0d51cdce)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-141004: Don't trigger `run-tests` when `Tools/check-c-api-docs/ignored_c_api.txt` is changed (GH-143583)
(cherry picked from commit 1176facbf2)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
- Gather all documented names into a set in a single pass.
This makes the check much faster.
- Do not match substrings (e.g. documenting `PyErr_WarnEx`
doesn't mean that `PyErr_Warn` is documented)
- Consider `PY`-prefixed names (a lot of old macros use this)
(cherry picked from commit 234a15dc4e)
In optimized and `-Og` builds, arguments and local variables are frequently
unavailable in gdb. This makes `py-bt` fail to print anything useful. Use the
`PyThreadState*` pointers `_Py_tss_gilstate` and `Py_tss_tstate` to find the
interpreter frame if we can't get the frame from the
`_PyEval_EvalFrameDefault` call.
(cherry picked from commit 49c3b0a67a)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit (GH-142455)
(cherry picked from commit bcf90de8ba)
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
Fix typo in `Tools/wasm/README.md` (GH-142426)
(cherry picked from commit 719d7960e2)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Introduce `build-python` and `build-host` subcommands for `Tools/wasm/wasi` (GH-142266)
It should make it easier when you need to rebuild just the e.g. host Python, but it requires ./configure to run.
(cherry picked from commit 58e1c7a16f)
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Emma Smith <emma@emmatyping.dev>
* gh-141004: Add a CI job ensuring that new C APIs include documentation (GH-142102)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
(cherry picked from commit 1a7824a927)
---------
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Being more flexible in when not to explicitly set the sysroot when compiling for WASI (GH-142242)
(cherry picked from commit c5252045d3)
Co-authored-by: Brett Cannon <brett@python.org>
The dataclasses `__init__` function is generated dynamically by a call to `exec()` and so doesn't have deferred reference counting enabled. Enable deferred reference counting on functions when assigned as an attribute to type objects to avoid reference count contention when creating dataclass instances.
(cherry picked from commit ce79154176)
Co-authored-by: Edward Xu <xuxiangad@gmail.com>
gh-140260: fix data race in `_struct` module initialization with subinterpreters (GH-140909)
(cherry picked from commit 63548b3699)
Co-authored-by: Shamil <ashm.tech@proton.me>
gh-140312: Set lltrace on JIT debug builds (GH-140313)
(cherry picked from commit f701f98052)
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Mark Shannon <mark@hotpy.org>
Make printing log lines to the terminal a little cleaner when building WASI (GH-140772)
(cherry picked from commit abd19eddee)
Co-authored-by: Brett Cannon <brett@python.org>
GH-140768: Warn when the WASI SDK version doesn't match the supported version (GH-140769)
(cherry picked from commit 95a3564869)
Co-authored-by: Brett Cannon <brett@python.org>
* [3.14] gh-139748: fix leaks in AC error paths when using unicode FS-based converters (GH-139765)
(cherry picked from commit b04a57deef)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
GH-137484: Have `Tools/wasm/wasi` use the build triple instead of "build" (GH-37485)
This should help prevent issuse where something like a container is used to do one build and then someone tries to build again locally.
(cherry picked from commit 0953200b13)
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
GH-137243: Have `Tools/wasm/wasi` detect WASI SDK installs in `/opt` when the release tarball is extracted (GH-137244)
(cherry picked from commit 2f1a9f2ed4)
Co-authored-by: Brett Cannon <brett@python.org>
Touch up `Setup.local` handling in `Tools/wasm/wasi` (GH-137051)
The comment in the generated file is now more self-explanatory. The checks for unexpected file contents are also strengthened.
(cherry picked from commit ec7fad79d2)
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Zachary Ware <zach@python.org>