To avoid duplicate content in the Enum HOWTO and
API documentation which is not automatically synced,
the section about supported __dunder__ and _sunder
names is moved from HOWTO to API docs.
See also https://github.com/python/cpython/pull/136791
(cherry picked from commit 629a363ddd)
Co-authored-by: Rafael Weingartner-Ortner <38643099+RafaelWO@users.noreply.github.com>
gh-146197: Run -m test.pythoninfo on the Emscripten CI (#146332)
(cherry picked from commit a57209eb98)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
gh-108907: ctypes: Document _type_ codes (GH-145837)
Add `_SimpleCData._type_` docs.
Add type codes to the summary table.
Cross-link `struct`, `array`, and `ctypes`; throw in `numpy` too.
(Anyone wanting to add a code should be aware of those.)
Add `py_object`, and `VARIANT_BOOL` for completeness.
(cherry picked from commit 1114d7f7f8)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Docs: replace all `datetime` imports with `import datetime as dt` (GH-145640)
(cherry picked from commit 83360b5869)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Also fix a few related issues in the pyatomic headers:
* Fix _Py_atomic_store_uint_release in pyatomic_msc.h to use __stlr32
on ARM64 instead of a plain volatile store (which is only relaxed on
ARM64).
* Add missing _Py_atomic_store_uint_release to pyatomic_gcc.h.
* Fix pseudo-code comment for _Py_atomic_store_ptr_release in
pyatomic.h.
(cherry picked from commit 1eff27f2c0)
gh-146092: Raise MemoryError on allocation failure in _zoneinfo (GH-146165)
(cherry picked from commit 6450b1d142)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-91279: Note `SOURCE_DATE_EPOCH` support in `ZipFile.writestr()` doc (GH-139396)
(cherry picked from commit 5ad738f8fb)
Co-authored-by: Wulian233 <1055917385@qq.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Add tests for corner cases: NULL pointers and out of range values.
(cherry picked from commit ab47892c32)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-145754: Update signature retrieval in unittest.mock to use forwardref annotation format (GH-145756)
(cherry picked from commit d357a7dbf3)
Co-authored-by: Matthias Schoettle <git@mattsch.com>
This allows us to change the test arguments from the python repo rather
than having to change buildmaster-config.
(cherry picked from commit 6b5511d66b)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Adds a standalone target for building all dependencies so that the buildbot
script is independent of a specific dependency list.
(cherry picked from commit db11623694)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Configure node version as part of the emscripten build script, and install
that node version if it isn't available.
(cherry picked from commit 91e1312b95)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
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)
Fix error handling in _PyFloat_FromDouble_ConsumeInputs() used by
_BINARY_OP_ADD_FLOAT, _BINARY_OP_SUBTRACT_FLOAT and
_BINARY_OP_MULTIPLY_FLOAT opcodes. PyStackRef_FromPyObjectSteal()
must not be called with a NULL pointer.
Fix also _BINARY_OP_INPLACE_ADD_UNICODE opcode.
- Add leading space so that the spacing between the previous annotation
and the thread safety annotation looks correct.
- Remove trailing period from the link to the thread safety level.
(cherry picked from commit 580043dfae)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Provides a `run` command in the Emscripten build tooling, and adds
environment variable configuration for EMSDK_CACHE, CROSS_BUILD_DIR
and QUIET.
(cherry picked from commit abd5246305)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
gh-146092: Handle _PyFrame_GetFrameObject() failures properly (#146124)
* Fix _PyFrame_GetLocals() and _PyFrame_GetLocals() error handling.
* _PyEval_ExceptionGroupMatch() now fails on _PyFrame_GetLocals()
error.
(cherry picked from commit e1e4852133)
gh-146093: Fix csv _set_str(): check if PyUnicode_DecodeASCII() failed (GH-146113)
The function can fail on a memory allocation failure.
Bug reported by devdanzin.
(cherry picked from commit 724c7c8146)
Co-authored-by: Victor Stinner <vstinner@python.org>
Cache one datachunk per tstate to prevent alloc/dealloc thrashing when repeatedly hitting the same call depth at exactly the wrong boundary.
Move new _ts member to the end to not mess up remote debuggers' ideas of the
struct's layout. (The struct is only created by the runtime, and the new
field only used by the runtime, so it should be safe.)
(cherry picked from commit 706fd4ec08)
Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* 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)
Docs: a brief note in the sets tutorial about order (GH-145984)
(cherry picked from commit 4f5e79805e)
Docs: a brief note in the sets tut about order
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
The test doesn't actually test any pyrepl code (it runs Python with -S)
and has a race condition that causes intermittent timeouts on CI.
(cherry picked from commit e18abc6a1f)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-145599, CVE 2026-3644: Reject control characters in `http.cookies.Morsel.update()` (GH-145600)
Reject control characters in `http.cookies.Morsel.update()` and `http.cookies.BaseCookie.js_output`.
(cherry picked from commit 57e88c1cf9)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
gh-145649: Fix man page text wrapping for -X option (GH-145656)
Replace hardcoded space indentation with proper troff macros
(.TP, .RS/.RE, .IP) for -X sub-options so text wraps correctly
at any terminal width.
(cherry picked from commit 36b5284f04)
Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Docs: fix a form error and a grammatical error in float.rst (GH-140989)
(cherry picked from commit 70397fd103)
Co-authored-by: RayXu <xu_ruihong2009@163.com>
gh-140814: Fix freeze_support() setting start method as side effect (GH-144608)
freeze_support() called get_start_method() without allow_none=True,
which locked in the default start method context. This caused a
subsequent set_start_method() call to raise "context has already been
set". Use allow_none=True and accept None as a matching value, since
spawn.freeze_support() independently detects spawned child processes.
Test that freeze_support() does not lock in the default start method,
which would prevent a subsequent set_start_method() call.
(cherry picked from commit ee5318025b)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>