6661 Commits
Author SHA1 Message Date
Ivy Xu b63ab245ec gh-110721: Remove undefined _Py_Offer_Suggestions in pycore_pyerrors.h (#154664) 2026-10-25 17:29:03 +00:00
Inada NaokiandEmma Smith b26fc41b5c Remove obsolete and unused configure macros (#159513)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
2026-10-25 05:18:16 +00:00
Neil Schemenauer 00c54508c6 gh-159564: Make weakref dereference lock-free. (#159578) 2026-10-24 14:56:31 +00:00
46edd6fa41 gh-89730: Implement support for Encrypted Client Hello (ECH) in ssl (GH-160318)
Co-authored-by: irl <iain@learmonth.me>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2026-10-23 20:02:23 -04:00
Petr ViktorinandItamar Oren 18c935f72d gh-157384: Unify _Py_ext_module_loader_info initialization (GH-157758)
- Unify `_Py_ext_module_loader_info_init*` functions. The “core” one was entirely unused, and the difference between “builtin” and “extension” can be expressed in arguments.
- Consolidate getting & checking the module name from spec. (This improves error message wording for `imp.create_builtin` with empty name.)
- Allow non-ASCII names.

Core modules (`sys` and `builtins`) still don't go through the routine.

Co-authored-by: Itamar Oren <itamarost@gmail.com>
2026-10-23 22:01:22 +02:00
Petr Viktorin 8335bcbf26 gh-160208: Add a private wrapper around __STDC_VERSION__ (GH-160376)
The wrapper is undefined on C++, where it can have an arbitrary
compiler-specific value.
2026-10-23 17:40:21 +02:00
Russell Keith-Magee ef08833eec gh-131999: Add support for tvOS, visionOS and watchOS. (#159944)
Add support for tvOS, visionOS and watchOS. This is mostly configuration
updates and testbed projects to support deploying to the new platforms.

Also includes a mimalloc change to support arm64_32 that has been contributed 
upstream.
2026-10-23 08:36:57 -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
Cody MaloneyandClaude Opus 5.5 3fc4d1f9b3 gh-87613: Allow Argument Clinic vectorcall on heap types (#160115)
Heap types have no static type object so switch from `Py_Is` to an
assert that the shadowed `tp_new` / `tp_init` function is the expected
one to validate the vectorcall is only used with the right type.

Heap types can have zero-argument `__new__` and `__init__` so add
support  for that producing the same error message via a new helper
`_PyArg_NoPositionalStack()`.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 03:13:30 +00:00
Donghee Na 9f3d5067f3 gh-159111: Add missing downstream changes when upgrade to 2.5.2. (gh-160207) 2026-10-21 23:26:29 -07:00
Timur Mamedov 4ecf6ca1b3 gh-151818: Fix double-free in _CALL_LIST_APPEND on allocation failure (#151826)
_CALL_LIST_APPEND stole the arg stackref via PyStackRef_AsPyObjectSteal
and passed it to _PyList_AppendTakeRef. When the list's backing array
failed to grow, _PyList_AppendTakeRef decreffed the item, but the stale
stackref remained on the value stack. The exception unwinder then closed
it a second time, causing a double-free / use-after-free.

Fix by giving _PyList_AppendTakeRef a separate reference via Py_NewRef
and closing the stackref explicitly on success. On the error path the
stackref still holds a valid reference, so the exception unwinder can
safely close it.
2026-10-21 21:52:56 -07: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
Serhiy StorchakaandGregory P. Smith ab5187ce84 gh-62222: Fix and extend quoted-printable decoding (GH-152679)
binascii.a2b_qp() and quopri now leave an invalid "=" escape in place and
rescan the following character instead of consuming it, like email.quoprimime
and other decoders (b'==41' now decodes to b'=A').

Add an opt-in strip_ws parameter to binascii.a2b_qp(), quopri.decode(),
quopri.decodestring() and email.quoprimime.decode() to strip trailing
whitespace per RFC 2045.  It is false by default everywhere except
email.quoprimime.decode(), preserving every existing default.

Also document that email's get_payload(decode=True) does not strip trailing
whitespace, contrary to RFC 2045.

Register the new "strip_ws" argument name in the global objects tables
(make regen-global-objects), needed by static builds where binascii is
compiled into the core, and replace an unresolved :func: reference to the
undocumented email.quoprimime.decode with a literal.

* gh-62222: Make strip_ws parameters keyword-only

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-10-22 00:22:49 +00:00
Yury Selivanov cf690004e3 gh-139122: Reimplement base UUID type, uuid4(), and uuid7() in C (#139123)
The C implementation considerably boosts the performance of the key UUID operations:

------------------------------------
Operation                    Speedup
------------------------------------
uuid4() generation            15.01x
uuid7() generation            29.64x
UUID from string               6.76x
UUID from bytes                5.16x
str(uuid) conversion           6.66x
------------------------------------

Summary of changes:

* The UUID type is reimplemented in C in its entirety.

* The pure-Python is kept around and is used of the C implementation
  isn't available for some reason.

* Both implementations are tested extensively; additional tests are
  added to ensure that the C implementation of the type follows the pure
  Python implementation fully.

* The Python implementation stores UUID values as int objects. The C
  implementation stores them as `uint8_t[16]` array.

* The C implementation has faster hash() implementation but also caches
  the computed hash value to speedup cases when UUIDs are used as
  set/dict keys.

* The C implementation has a freelist to make new UUID object
  instantiation as fast as possible.

* uuid4() and uuid7() are now implmented in C. The most performance
  boost (10x) comes from overfetching entropy to decrease the number of
  _PyOS_URandom() calls. On its own it's a safe optimization with the
  edge case that Unix fork needs to be explicitly handled. We do that by
  comparing the current PID to the PID of when the random buffer was
  populated.

* Portions of code are coming from my implementation of faster UUID
  in gel-python [1]. I did use AI during the development, but basically
  had to rewrite the code it generated to be more idiomatic and
  efficient.

* The benchmark can be found here [2].

* This PR makes Python UUID operations as fast as they are in NodeJS and
  Bun runtimes.

[1] https://github.com/MagicStack/py-pgproto/blob/b8109fb311a59f30f9947567a13508da9a776564/uuid.pyx

[2] https://gist.github.com/1st1/f03e816f34a61e4d46c78ff98baf4818
2026-10-21 14:17:07 -07:00
Nathan Goldbaum 5def03d7d6 gh-159808: Sync documented C API structs with their headers (GH-159812) 2026-10-21 17:31:37 +00:00
Peter BiermaandPetr Viktorin 01ff2e22e1 gh-141004: Document remaining parts of the public C API (GH-159892)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-10-21 19:21:48 +02:00
Gr4ph0s 39bc958bf9 gh-159860: Adjust QSBR cache line size from 64 to 128 on AArch64 (gh-159862) 2026-10-20 20:06:55 +00:00
Neil Schemenauer 4bb1dadff4 gh-158197: Fix split dict iteration during concurrent deletion (gh-158686)
Read insertion order from the iterator's captured values snapshot instead
of re-reading ma_values and asserting against a concurrently changing
size. Retry under the dictionary lock when a value slot has been cleared.

Make insertion-order writes atomic and publish size changes with release
stores, pairing with the iterator's size load. Keep order-byte accesses
relaxed. Add _Py_atomic_store_uint8_release() and
FT_ATOMIC_STORE_UINT8_RELEASE() for this.
2026-10-20 12:33:27 -07:00
Kumar Aditya cb12c5e514 gh-157361: Implement aiter() in Python instead of C (#157687)
gh-157361: Implement aiter() in Python instead of C

Move both forms of aiter() into the frozen _pybuiltins module and remove
the C async_callable_iterator types. The callable form now returns an
iterator whose __anext__() is a plain coroutine, so call-graph tools can
see through it into the awaited result of the callable.
2026-10-20 15:33:36 +05:30
7641c5d691 gh-145019: improve SyntaxError when match patterns bind different names (#145939)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-10-19 13:02:04 -07:00
Pablo Galindo Salgado 6af655301a gh-159465: Improve incomplete input detection (#159466)
* gh-159465: Improve incomplete input detection

* gh-159465: Track newline effects and preserve parser layout

* gh-159465: Share incomplete-input error cleanup
2026-10-18 11:54:19 +01:00
Neil Schemenauer 010bebbf9f gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269)
Setting __name__, __qualname__, __doc__ or __module__ on a function
stopped the world in the free-threaded build since gh-154826 and
gh-154851, making functools.wraps() orders of magnitude slower with
multiple threads.

Use the per-object critical section and _PyObject_XSetRefDelayed()
instead, as gen_set_name() already does.  Use acquire loads in the
readers and hold strong references across error reporting, tracing, and
eval-frame recording that may execute Python or detach the thread.  The
__code__, __defaults__, __kwdefaults__ and __closure__ setters still
stop the world to clear func_version.

Document synchronization requirements for direct field access and the
lifetime of borrowed function attributes.
2026-10-16 20:24:12 -07:00
Neil Schemenauer 801377967f gh-158973: Reset the warnings lock after fork in the child (gh-158974) 2026-10-16 20:11:09 -07:00
Victor Stinner a2c999bd8b gh-157710: There is no need to export _PyUnicode_IsModifiable() (#159601)
_PyUnicodeWriter_CanWrite() doesn't call _PyUnicode_IsModifiable(),
but reimplement the function.
2026-10-17 00:36:48 +00:00
Victor Stinner 35a000974a Revert "gh-158445: Allocate memory in the heap in Py_GetVersion() (#158608)" (#159519)
This reverts commit f5e913c7f7.

Truncating the static buffer to 20 bytes caused a regression in debuggers
and crash reporters checking `version` static buffer, see:
https://github.com/python/cpython/pull/158608#issuecomment-6027641907
2026-10-16 10:49:53 +00:00
Brett Cannon 084aff869c GH-158628: Implement sys._wasi_info (GH-159039)
Starting off with WASI version, WASI SDK version, and whether cooperative multithreading is available. All values are required as WASI SDK is the officially  supported compiler according to PEP 11.
2026-10-13 23:53:38 +00:00
Savannah Ostrowski b9ccaccdc4 Post 3.16.0a1 2026-10-13 12:10:05 -07:00
Savannah Ostrowski 22d79d9840 Python 3.16.0a1 2026-10-13 08:05:54 -07:00
Pablo Galindo Salgado f892b11f22 gh-153569: Simplify tokenizer source views and reader ownership (#158849)
Move source access and logical spans into the tokenizer source API, and keep input and encoding ownership in the reader. Export the incremental decoder helper for parser generator extensions.
2026-10-13 13:01:17 +00:00
Gregory P. Smith 627eabf31c gh-129724: Intern string constants in the compiler, not per code object (GH-159193)
The compiler merges equal constants of a module through its constant
cache.  intern_constants() then ran on each code object and rebuilt a
frozenset (or, in the free-threaded build, a slice) when one of its
strings was replaced by an already interned one, so a constant shared by
several functions was copied for some of them depending on which strings
happened to be interned in the process.  The class body's __qualname__
constant and co_qualname had the same problem.  marshal then wrote
different bytes for the same source.

Intern the eligible strings of the final constants of each code unit
after optimization and before the code object is created.  Tuples are
updated in place; a frozenset or slice is rebuilt once and stored in the
constant cache so that later units get the same object.  The same code
is used in both builds.

Which strings are interned does not change, except that identifier-like
strings in slice constants are now interned in the default build too.

TestConstantsIdentity compares the identity graph and the marshal
output of code compiled in differently prepared processes, including
names tuples shared with constants.
2026-10-12 21:37:55 -07:00
Victor Stinner 8992704916 gh-144175: Remove internal _PyArg_ParseStack() function (#159150)
Replace internal _PyArg_ParseStack() with public PyArg_ParseArray()
in Argument Clinic.
2026-10-12 19:56:53 +02:00
Pablo Galindo Salgado fbbf4f48c4 gh-159137: Skip redundant GC resurrection analysis (#159138) 2026-10-10 22:46:49 +00: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
Kevin Newton bc12b7285f gh-158572: Add an external flag to interpreter frames (#158573)
Adds an `external` flag to a bit-packed byte on the
_PyInterpreterFrame struct in order to provide external frame
evaluators a way to distinguish VM-pushed frames vs externally-
pushed frames.
2026-10-08 16:45:03 -07:00
Victor Stinner e2c3c7e4dd gh-158942: Use more unique variable names in Py_MIN/MAX/ABS() (#158969)
If Py_MIN/MAX/ABS() macros are called on an existing "_x" or "_y"
variable name, the external variable is used instead of macro local
variable. So use more unique names in the macros to avoid
the issue.

Add test_min_max_abs_macros() to _testlimitedcapi.
2026-10-08 17:48:43 +00:00
Victor Stinner 15dd7356f3 gh-158893: Add internal _Py_strerror() function (#158982)
Add a new internal _Py_strerror() function to Python/fileutils.c. It
uses strerror_r() if available, or use strerror() otherwise.

Replace all strerror(code) calls with _Py_strerror(code).
2026-10-07 20:31:27 +00:00
Vasiliy Kiryanov 2791c35cae gh-136872: Build pymalloc in sanitizer builds, but disable it by default (GH-157934)
--with-*address-sanitizer and --with-memory-sanitizer unconditionally
disabled pymalloc (even when --with-pymalloc was given explicitly).

Enable it, so that it's available with `PYTHONMALLOC=pymalloc`.
Disable it by default on the affected sanitizer builds.
2026-10-07 18:05:37 +02:00
Victor Stinner ba9d96ff8d gh-149044: Avoid C++ warnings in PySlot_END macro (GH-158866)
Initialize all fields in the macro. Otherwise, g++ -Wall -Wextra
complains that some fields are not initialized
[-Werror=missing-field-initializers]:

  error: missing initializer for member ‘PySlot::sl_flags’
  error: missing initializer for member ‘PySlot::<anonymous>’
  error: missing initializer for member ‘PySlot::<anonymous>’
2026-10-07 14:12:32 +02:00
Victor Stinner ec14f81e74 gh-158842: Add Py_SETREF() and Py_XSETREF() to the limited C API (#158843)
Test these macros with the limited C API in _testlimitedcapi and
test_cext.

Move also other tests (refcount, Py_CLEAR, etc.) to _testlimitedcapi.
2026-10-06 21:13:49 +02:00
197607e865 gh-156049: Add support for building with HWAsan (#156721)
Co-authored-by: Florian Mayer <fmayer@google.com>
Co-authored-by: Anna <araslanova.anna.a@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-10-06 19:34:53 +01:00
Victor Stinner 85c03d47a2 gh-158810: Use _Py_TYPEOF in Py_ARRAY_LENGTH() (#158838)
Fix the compiler warning "extension used" when building test_cext
with clang.

* test_cext no longer overrides the CC environment variable if it's
  already defined.
* test_cext now also logs __STRICT_ANSI__ macro.
2026-10-06 00:06:09 +00:00
3f9118f1d1 gh-151157: Speed up PyObject_CallMethod via _PyObject_GetMethod (#151158)
* Speed up PyObject_CallMethod via _PyObject_GetMethod

PyObject_CallMethod (and _PyObject_CallMethod, PyEval_CallMethod,
_PyObject_CallMethodId and the _SizeT variant) resolved the method with
PyObject_GetAttr, which builds a temporary bound-method object on every call,
then called it.

Resolve the method with _PyObject_GetMethod instead (the same lookup the
interpreter uses for obj.name(...)) and call it directly via
_PyObject_VectorcallPrepend, skipping the bound-method allocation.  Behaviour
is unchanged: same attribute semantics, same "attribute of type ... is not
callable" error, and the historical
PyObject_CallMethod(o, m, "O", tuple) -> o.m(*tuple) unpacking.

The shared helper callmethod() and _PyObject_CallMethodFormat() are no longer
needed: their only caller (traceback.c) now uses PyObject_CallFunction, so both
are removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Use _PyObject_GetMethodStackRef so method calls scale in free-threading

Resolve the method in callmethod_va() via _PyObject_GetMethodStackRef()
instead of _PyObject_GetMethod(). The StackRef variant returns the method
as a deferred reference, avoiding the per-call atomic refcount on the
shared method object that otherwise serializes threads in the
free-threaded build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* rename to callmethod

* review comments

* review comments

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2026-10-05 18:44:28 +00:00
cfd6cf7154 gh-157407: Use _PyUnicode_AsUTF8NoNUL for AC 's' and 'z' converters (#158210)
* gh-157407: Use _PyUnicode_AsUTF8NoNUL for AC 's' and 'z' converters

The code was doing the same as the helper added in GH-111957 but inline.
That resulted in significantly more `.text` for most functions. Refactor
the Arguemnt Clinic converters code to deduplicate a bit while keeping
generated code close to original.

On my Linux x64 box this reduces `.text` by ~6200 bytes in a clang
release build (no PGO or LTO). Performance is flat.

The helper was already exported for `_sqlite3`, update the comment that
it is used in AC generated code as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Update Include/internal/pycore_unicodeobject.h

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>

* Remove NEWS, add period

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2026-10-05 17:03:27 +00:00
Victor Stinner b2bfbce9a2 gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ (#158812) 2026-10-05 13:30:16 +02:00
Maurycy Pawłowski-WierońskiandPablo Galindo Salgado 5fecd448bb gh-155811: Add a seqcount to gc_stats to prevent torn reads (#155828)
* update_seq

* no need for XCHGL, MOVL is enough?

* gh-155811: Retry an inconsistent GC snapshot once

---------

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2026-10-05 01:49:56 +00:00
Stan UlbrychandVictor Stinner b93fb19a6e Run a job that the test suite with MSan to the CI (#158625)
* Run the test suite with MSan in CI

* Additional fixes

* Add `_Py_MSAN_UNPOISON_STRING`

* Apply Victor's suggestions

Co-authored-by: Victor Stinner <victor.stinner@gmail.com>

* Apply Victor's suggestions

Co-authored-by: Victor Stinner <victor.stinner@gmail.com>

---------

Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
2026-10-05 02:11:42 +01:00
Maurycy Pawłowski-WierońskiandPablo Galindo Salgado 7d25916b41 gh-154194: Degrade frames in Tachyon instead of failing the sample (#154195)
* degrade gracefully

* news

* better NEWS wording

* do not raise on MAX_REMOTE_STR_READ

* bye MAX_REMOTE_STR_READ

* fix -m asyncio ps|pstree

* test truncation and linetable sentinel

* simpler

* simpler

* redundant now

* respect #157790 in the news

---------

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2026-10-05 00:37:21 +00:00
Victor Stinner d19febb00c Rework locale encoding C functions (#158680)
Add output_length to _Py_EncodeLocale(), _Py_EncodeUTF8(),
encode_current_locale() and encode_ascii(). So unicode_encode_locale() and
wstr_to_utf8() can now use the output_length, instead of having to compute
strlen().

* Rename functions:

  * _Py_DecodeUTF8Ex() => _Py_DecodeUTF8()
  * _Py_EncodeUTF8Ex() => _Py_EncodeUTF8()
  * _Py_EncodeLocaleEx() => _Py_EncodeLocale()
  * _Py_DecodeLocaleEx() => _Py_DecodeLocale()

* Add tests on Py_DecodeLocale() and Py_EncodeLocale() in test_codecs.
  Clarify also their documentation.
* _Py_EncodeLocale() and _Py_DecodeLocale() now sets all output parameters on
  error. Add more tests on these output parameters.
* Add encode_current_locale_impl() to simplify encode_current_locale().
* Remove reason parameter of _Py_EncodeLocale() and _Py_DecodeLocale() to
  simplify the code. Only the UTF-8 decoder used specific reasons.
* _Py_EncodeUTF8() now uses size_t instead of Py_ssize_t to iterate
  on the input string.
* On error, encode_current_locale_impl() now returns ENCODE_ERROR (new
  constant) instead of DECODE_ERROR.
* Mark _Py_EncodeLocaleRaw() as static (it's not used outside fileutils.c).
2026-10-04 23:22:18 +02:00
Victor Stinner f5e913c7f7 gh-158445: Allocate memory in the heap in Py_GetVersion() (#158608)
Py_GetVersion() now allocates memory on the heap, instead of using a
static buffer, to no longer truncate the version if it's longer than
299 bytes.

Update Py_GetCompiler() and Py_GetBuildInfo() tests: they are now
always a part of sys.version.
2026-10-03 15:15:08 +02:00
00a1c3a0c9 gh-158140: Resolve lazily imported sibling submodules independently (#158521)
* gh-158140: Resolve lazy siblings through the pending-child registry

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
2026-10-02 19:20:04 +02:00