1811 Commits
Author SHA1 Message Date
Christian HeimesandClaude Opus 4.8 7dd8b4736a gh-160040: Distrust compromised eMudhra intermediate CA keys (CVE-2026-115557) (GH-160042)
The ssl module now rejects TLS certificate chains that contain any of a set of
compromised eMudhra intermediate CA keys.  This is an extraordinary measure and
a last line of defense: removing trust is primarily the job of the platform root
store, and the built-in denylist only blocks connections while that update has
not yet reached the OS, a container image, or a bundled trust store in various
Python packages.  Entries are added to the denylist only under a very high
threshold.

The denylist matches on the public key (the SHA-256 digest of the RFC-5280
SubjectPublicKeyInfo), so it also covers the cross-signed certificates that
reuse one of the distrusted keys.

---------

Signed-off-by: Christian Heimes <christian@python.org>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-10-24 05:40:49 +00:00
Lysandros Nikolaou e548b472f3 gh-153195: Allow splitting the PEG grammar into several files (#159917)
Add an @include meta to pegen: the rules of an included grammar file are
appended to the including file's rules. The C generator emits the rules
of each included file into a separate C file next to the main output.

Use it to move the invalid_* rules from Grammar/python.gram into
Grammar/invalid.gram, which generates Parser/parser_invalid.c.
2026-10-23 12:58:39 -07:00
Paul GanssleandStan Ulbrych 6854e79163 gh-158252: Add a C implementation for strptime (#158253)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-10-23 15:23:02 +00:00
Donghee Na aff7a2e23b gh-159111: Update vendored mimalloc to v2.5.2 (gh-159112)
* Update vendored mimalloc to v2.5.2

Upgrade mimalloc from v2.1.2 to v2.5.2 as-is from upstream.

v2.1.2: https://github.com/microsoft/mimalloc/releases/tag/v2.1.2
v2.5.2: https://github.com/microsoft/mimalloc/releases/tag/v2.5.2

* Re-apply CPython-specific changes to mimalloc v2.5.2

Most of the previous downstream changes were upstreamed in mimalloc
v2.1.3 - v2.1.7 (heap tags, _mi_heap_init/_mi_tld_init, MI_PRIM_THREAD_ID,
sub-processes, heap walk optimizations, platform fixes) and are dropped.

Remaining CPython-specific changes, all marked with a "CPython" comment:

- QSBR delayed page freeing for free-threaded builds (gh-115103,
  gh-145615): mi_page_t/mi_heap_t fields and _PyMem_mi_* hooks in
  page.c, heap.c and segment.c.
- debug_offset: preserve the first bytes of a PyObject (ob_tid, refcount
  fields) when filling freed or uninitialized memory in debug builds
  (gh-115491).
- Atomic mi_block_t.next loads/stores to avoid TSAN reports (gh-129748).
- Relax the owning thread assertion in _mi_free_delayed_block for
  free-threaded builds, since the GC traverses heaps of other threads.
- Call _mi_heap_delayed_free_partial() in mi_heap_visit_blocks()
  (gh-112532).
- Only count reclaimed pages up to MI_MEDIUM_OBJ_SIZE_MAX as a
  "right page" in mi_segment_reclaim (gh-115103).
- Rename the weak _ZSt15get_new_handlerv symbol and disable the
  mi_is_in_heap_region debug warning.
- Zero-initialize _mi_page_empty instead of a positional initializer.

* Update the free-threaded build to mimalloc v2.5.2 changes

mimalloc v2.1.4 replaced the list of abandoned segments with per-arena
bitmaps and introduced sub-processes (mi_subproc_t) to keep abandoned
segments of separate interpreters apart. Use them instead of the
CPython-specific mi_abandoned_pool_t:

- Each interpreter owns a mi_subproc_t created in init_interpreter().
- tstate_mimalloc_bind() sets tld->segments.subproc and uses the
  upstream _mi_heap_init() signature.
- The GC and sys.getallocatedblocks() visit abandoned segments with
  _PyMem_mi_visit_abandoned_blocks(), the upstream cursor API without
  the mi_option_visit_abandoned requirement, while STW.

* Update NEWS.d

* fix MSAN

* fix TSAN

* fix test_cext

* Disable THP

* Address code review

* Address code review

* Address code review

* nit

* Address code review

* Address code review
2026-10-21 17:41:07 -07:00
Stan UlbrychandPetr Viktorin 0071fb5111 gh-158876: Update bundled Expat to 2.9.0 (GH-158881)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-10-20 17:37:13 +00:00
Wulian233 9c15cc9d69 gh-159113: Update PCBuild/find_python.bat to allow discovery of Python 3.14 and 3.15 (GH-159114) 2026-10-12 19:09:50 +01:00
Hood Chatham 0ec3aee262 gh-129040: Use wasm-gc to handle pointer casts in wasi (GH-158617)
This makes it so that in wasi builds if `-DPY_CALL_TRAMPOLINE` is passed, a call trampoline adaptor is used to prevent traps when there is a call signature mismatch between a C slot handler and the signature that the interpreter uses to call it.

This requires Clang >= 22. PEP 11 specifies that builds of Python 3.15 use WASI SDK version 33 which includes clang 23.1.0, so this could be used with Python 3.15 WASI builds but not earlier ones.

It requires a WebAssembly runtime that supports wasm-gc. Wasmtime has supported wasm-gc since version 27.0 released November 25, 2024. Some other runtimes still don't support it, but for those runtimes people can use builds with the trampoline disabled.

This also removed the Emscripten trampoline support for JS runtimes with no wasm-gc support. This removes a lot of implementation complexity and allows WASI and Emscripten to share code. The main concern is that it drops support for some very old iPhones, but every iPhone model released since 2018 is compatible with versions of Safari that support wasm-gc.

Tests were added that define handlers with various wrong numbers of arguments. The tests also run on non-webassembly platforms since they should work there as well.
2026-10-09 22:25:44 +00:00
Chris Eibl 9028df36bb gh-157789: Use compiler option `-Og` in case of clang-cl debug builds (#157791)
Use compiler option ``-Og`` in case of clang-cl debug builds on Windows to reduce stack usage.
2026-10-06 06:36:02 +00:00
Victor Stinner a831abba14 gh-158445: Add C API tests on build information functions (#158603)
Add tests on functions:

* Py_GetBuildInfo()
* Py_GetCompiler()
* Py_GetCopyright()
* Py_GetPlatform()
* Py_GetVersion()

Changes:

* Add Modules/_testlimitedcapi.c and
  Lib/test/test_capi/test_build.py files.
* Add internal _Py_GetBuiltWithAssert() function.
* Reimplemenet support.built_with_c_assertions() using
  _Py_GetBuiltWithAssert() to cover more cases like buildbots using
  CFLAGS=-UNDEBUG in release mode.
2026-10-02 14:43:44 +00:00
Zachary Ware 115c297fdc gh-158010: Update Windows builds to use OpenSSL 3.5.9 (GH-158432) 2026-09-29 16:23:46 +00:00
8c056c33aa gh-158102: Add tests for the slice C API (GH-158120)
Test PySlice_Check(), PySlice_New(), PySlice_GetIndices(), PySlice_Unpack(),
PySlice_AdjustIndices() and PySlice_GetIndicesEx() -- both the macro and the
deprecated function.

Document the length and step precondition of PySlice_AdjustIndices()

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-09-25 12:49:12 +00:00
Pablo Galindo Salgado 2a96282d9a gh-153569: consolidate tokenizer input, layout, and diagnostics (#157055)
* gh-153569: move tokenizer input state and relocation into the reader

* gh-153569: borrow diagnostic lines through the source API

* gh-153569: group indentation and logical-line state

* gh-153569: remove unused tokenizer cursor and source lookup APIs

* gh-153569: report tokenizer diagnostics without rewinding the scanner

* gh-153569: use tokenizer views and remove obsolete API remnants
2026-09-24 16:26:47 +00:00
Stan Ulbrych 5f1f21894f gh-157953: Update bundled Expat to 2.8.5 (#157957) 2026-09-23 14:46:18 +01:00
Victor Stinner 7cfb6552ff gh-148233: Add Py_HashBuffer() to the limited C API (#157966) 2026-09-23 11:17:39 +02:00
Steve DowerandChris Eibl 9ea05d4b8f gh-153668: Temporarily disable unicodectype.c optimization on WinARM64 due to compiler bug (#153669)
* Only disable during Release (not PGO)

* Update PCbuild/pyproject.props

---------

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2026-09-20 07:31:17 +00:00
Victor StinnerandPetr Viktorin 8bcbcf8cfc gh-155742: Check singletons consistency at Python exit (#157572)
In debug mode at Python exit, check if immutable singleton objects
have been modified by mistake to detect bugs in C extensions.

Add tests corrupting bytes, str, bool and int singleton objects.

Add pycore_global_objects_fini.h internal header file.
pycore_global_objects_fini_generated.h is now fully generated by the
script.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-09-17 16:03:45 +02:00
Kumar Aditya 0a6c1ed341 gh-157361: Implement anext() in Python instead of C (#157362) 2026-09-16 18:58:59 +05:30
Victor Stinner bbdf31d5d6 gh-155907: Move PyMarshal C API tests to test_capi (#157417)
Add Modules/_testcapi/marshal.c and
Lib/test/test_capi/test_marshal.py.
2026-09-13 15:02:31 +00:00
Pablo Galindo Salgado 7bfa97f4dc gh-153569: hide tokenizer state behind token and source operations (#156654)
Make pegen and _tokenize consume tokenizer operations instead of accessing the tokenizer layout. Return token kind, span, location, and raw-string context together, so parser actions use the context of the cached token.

Represent persistent scanner positions as offsets and remove pointer save/restore bookkeeping when input storage grows.
2026-09-12 14:30:00 +01:00
Kumar Aditya 39a9a47516 gh-156228: Use PyMem_Raw allocators for OpenSSL in _ssl and _hashlib (#156229) 2026-09-02 18:26:17 +05:30
Serhiy StorchakaandClaude Opus 5 1620e0f1b5 gh-64862: Add the stop_exception parameter in iter() and aiter() (GH-156298)
The iteration stops when the callable raises the specified exception (an
exception class or a tuple of exception classes).  It is keyword-only and
can be used without the stop value.  The second parameter of iter() is now
named stop_value and can be passed as a keyword argument.

aiter() now accepts the same parameters, which it never had before: the
callable is called and its result is awaited for every __anext__().

If the callable raises StopIteration (StopAsyncIteration in aiter()) which
does not match stop_exception, it is replaced with RuntimeError, as PEP 479
and PEP 525 do for generators.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 15:55:32 +03:00
Serhiy Storchaka 0e8100a140 gh-85470: Delay load ole32.dll in the _ctypes module (GH-155435)
ole32.dll pulls in user32.dll, which makes the system treat the process as
a GUI process and stop sending logoff and shutdown console control events
to it.  It is only needed for ProgIDFromCLSID() when formatting a COM error.
2026-08-29 21:04:01 +03:00
Zachary Ware b7ce9c3f1a gh-156369: Update Windows builds to OpenSSL 3.5.8 (GH-156528) 2026-08-28 16:26:14 +00:00
Pablo Galindo Salgado f5dbcbafae gh-153569: Unify tokenizer input readers (#156472) 2026-08-28 17:26:05 +02:00
Pablo Galindo Salgado f54fd2ab6e gh-153569: Add tokenizer source and cursor primitives (#153587) 2026-08-26 12:38:22 +01:00
Steve Dower ee521e8ac1 gh-148750: Unfreeze encodings module to avoid import errors with zipped stdlib (GH-156183)
(Reverts fixes applied as part of gh-145278)
2026-08-24 20:19:30 +01:00
Stan Ulbrych 20e6c2fc7c gh-152023: Update Android and Windows builds to SQLite 3.53.4 (#155101) 2026-08-19 10:44:02 +01:00
Victor Stinner 29837a952c gh-155503: Add more PyType C API tests (#155505)
Add tests on functions:

* PyType_ClearCache()
* PyType_GetFlags()
* PyType_IsSubtype()
* PyType_Ready()

Move PyType limited C API tests from _testcapi to _testlimitedcapi.
Add a new Modules/_testlimitedcapi/type.c file.
2026-08-12 14:40:04 +02:00
Serhiy StorchakaandClaude Fable 5 d24d9d0f1d gh-76595: Add tests for PyCapsule_Import() (GH-154588)
Add _testcapi helpers to create a capsule with an arbitrary name and to call PyCapsule_Import(), and Python tests covering the current behavior: only the first component of the dotted name is imported, the rest are attribute lookups.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 18:01:56 +03:00
Kumar Aditya daf09e17bf gh-145685: per-type method cache implementation (#150160) 2026-07-21 14:11:22 +05:30
Steve Dower bd315837d8 gh-153511: Removes Tools/msi, Tools/nuget, and legacy py.exe launcher sources (GH-153512) 2026-07-20 22:25:12 +01:00
Zachary Ware 46e950fc0d gh-124111: Update Windows builds to Tcl/Tk 9.0.4 (GH-153901) 2026-07-18 09:52:10 -05:00
Pablo Galindo Salgado a2d3787105 gh-153569: Split tokenizer lexer into focused files (#153585) 2026-07-11 19:53:27 +01:00
Stan Ulbrych c22e9c9dae gh-152216: Update bundled expat to 2.8.2 (GH-152234)
* Update bundled expat to 2.8.2
* `make regen-sbom`
* Update download URL
* Drop warnings (yay!)
2026-07-10 11:40:12 -07:00
Harjoth Khara 106eb532ea gh-153438: Update NuGet download URL (GH-153482) 2026-07-10 12:13:08 +01:00
Victor Stinner d83d26724b gh-152132: Test Py_CompileString() in test_capi.test_run (#153470)
PyRun functions now raises ValueError if the start argument is
invalid.

* Add Modules/_testlimitedcapi/run.c.
* Rename _Py_CompileStringObjectWithModule() to
  _Py_CompileStringObject().
2026-07-10 03:36:31 +02:00
Serhiy StorchakaandClaude Opus 4.8 3ce7a1211c gh-152997: Support system locale encodings via an iconv-based codec (GH-153001)
Where the C library provides iconv(), the codecs module now exposes every
encoding iconv() knows but Python has no built-in codec for -- the POSIX
counterpart of the Windows code-page support.  Use it by name (e.g.
"cp1133"), or with an "iconv:" prefix to force it over a built-in codec.

The codec is a last-resort search function and never shadows a built-in.
Both directions pivot through native-endian UTF-32, keeping one input unit
per code point so error handlers get the exact string position.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 20:01:32 +03:00
Bart van der Braak 8c35afa221 gh-152919: Ensure nuget.org source exist before python install (GH-152919)
Ensure `nuget.org` source exist before `python` install
2026-07-03 09:27:56 +01:00
Zachary Ware ab8ebe9034 gh-151163: Update Android, macOS installer, and Windows builds to SQLite 3.53.2 (GH-151187) 2026-06-09 13:27:26 -05:00
Zachary Ware 6688b0c715 gh-151159: Update Windows builds to use OpenSSL 3.5.7 (GH-151183) 2026-06-09 17:09:19 +00:00
Serhiy Storchaka c3cd75afdf gh-151130: Add more tests for PyWeakref_* C API (GH-151131) 2026-06-09 11:11:17 +00:00
Adam Johnson 9242700c14 gh-149029: Update SQLite to 3.53.1 for binary releases (#149767) 2026-05-27 18:03:34 -04:00
Steve Dower 1c5fe21eb2 gh-149786: Fixes venvlauncher builds on Windows free-threaded (GH-149847) 2026-05-15 14:43:41 +01:00
Zachary Ware c62c3710dc gh-124111: Update Windows build to use Tcl/Tk 9.0.3 (GH-149477) 2026-05-14 12:47:28 -05:00
Petr Viktorin fa81cd976a gh-140550: Update xxlimited with 3.15 limited API (GH-142827) 2026-05-13 18:35:50 +02:00
Zachary Ware d13fc36f73 gh-124111: Only set TCLSH_NATIVE for AMD64/ARM64 (GH-149443)
The Tcl 9 makefile.vc now uses TCLSH_NATIVE during the build process,
not just the installation.  We had been setting it to the installed
location of the x86 tclsh.exe, which does not yet exist when the x86
build process needs it.  That build doesn't actually need TCLSH_NATIVE,
though (there's a check specifically allowing TCLSH to be used if
MACHINE is IX86 and TCLSH_NATIVE is undefined), so don't set it.
2026-05-06 11:04:42 -05:00
Zachary Ware 2140b14a9b gh-124111: Fix tclWin32Exe value in tcltk.props for Tcl 9 (GH-149441) 2026-05-06 03:48:00 +00:00
Diego RussoandPablo Galindo Salgado 1e5d94274d GH-126910: Add GNU backtrace support for unwinding JIT frames (#149104)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2026-05-05 09:29:07 +01:00
Petr ViktorinandPeter Bierma 508b49845d gh-149044: Implement PEP 820 – PySlot: Unified slot system for the C API (GH-149055)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2026-05-05 09:18:04 +02:00
Steve DowerandPetr Viktorin 10f950c9bb gh-148690: Build Windows freethreaded binaries into separate directory and include python3t.dll on GIL-enabled (GH-149218)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-05-04 17:45:08 +01:00