Malcolm Smith [Wed, 28 Jan 2026 23:48:26 +0000 (23:48 +0000)]
gh-142387: Reduce Android testbed API level to 33 (#144315)
The emulator images for API level 34 and 35 have significant issues with image size and
internet connectivity. Reverts the default API level used for testbed testing to 33.
stratakis [Wed, 28 Jan 2026 13:30:17 +0000 (14:30 +0100)]
gh-144194: Fix mmap failure check in perf_jit_trampoline.c (#143713)
mmap() returns MAP_FAILED ((void*)-1) on error, not NULL. The current
check never detects mmap failures, so jitdump initialization proceeds
even when the memory mapping fails.
Now that the specializing interpreter works with free threading,
replace ENABLE_SPECIALIZATION_FT with ENABLE_SPECIALIZATION and
replace requires_specialization_ft with requires_specialization.
Also limit the uniquely referenced check to FOR_ITER_RANGE. It's not
necessary for FOR_ITER_GEN and would cause test_for_iter_gen to fail.
Sam Gross [Tue, 27 Jan 2026 21:38:50 +0000 (16:38 -0500)]
gh-120321: Add missing "return false" in gen_try_set_executing (gh-144291)
We didn't catch this because of a combination of:
1) falling through to the if-statement below works
2) we only specialized FOR_ITER_GEN for uniquely referenced generators,
so we didn't trigger the non-thread-safe behavior.
The code in test_makefile was attempting to ignore any
non-interesting files, but missed some corners:
1. There is never a *file* called `__pycache__`.
2. A directory containing only a `__pycache__` subdirectory should be
ignored.
3. A directory containing only hidden files should be ignored.
Simplify this all into a couple of filters that let us check for empty
lists.
Jeong, YunWon [Mon, 26 Jan 2026 16:40:56 +0000 (01:40 +0900)]
gh-142966: Make ctypes.POINTER.set_type also reset format (GH-142967)
Make the deprecated set_type method resets the format, using the
same code as in type initialization.
Implementation note: this was done in PyCPointerType_init
after calling PyCPointerType_SetProto, but was forgotten
after in PyCPointerType_set_type_impl's call to
PyCPointerType_SetProto.
With this change, setting the format is conceptually part of
setting proto (i.e. the pointed-to type).
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Jake Lishman [Mon, 26 Jan 2026 15:45:17 +0000 (15:45 +0000)]
gh-140557: Force alignment of empty `bytearray` and `array.array` buffers (GH-140559)
This ensures the buffers used by the empty `bytearray` and `array.array`
are aligned the same as a pointer returned by the allocator. This is a
more convenient default for interop with other languages that have
stricter requirements of type-safe buffers (e.g. Rust's `&[T]` type)
even when empty.
Serhiy Storchaka [Sat, 24 Jan 2026 11:13:50 +0000 (13:13 +0200)]
gh-142037: Improve error messages for printf-style formatting (GH-142081)
This affects string formatting as well as bytes and bytearray formatting.
* For errors in the format string, always include the position of the
start of the format unit.
* For errors related to the formatted arguments, always include the number
or the name of the formatted argument.
* Suggest more probable causes of errors in the format string (stray %,
unsupported format, unexpected character).
* Provide more information when the number of arguments does not match
the number of format units.
* Raise more specific errors when access of arguments by name is mixed with
sequential access and when * is used with a mapping.
* Add tests for some uncovered cases.
Alex Willmer [Thu, 22 Jan 2026 22:00:37 +0000 (22:00 +0000)]
gh-143513: Remove importlib.abc documentation for removed ABCs (#143605)
In 3.11 ResourceReader, Traversable, & TraversableResources moved from importlib.abc to importlib.resources.abc (commit e712a5b277866a71c195f38c1b5d87d9126dba3e).
Gregory P. Smith [Thu, 22 Jan 2026 17:21:07 +0000 (09:21 -0800)]
gh-144157: Optimize bytes.translate() by deferring change detection (GH-144158)
Optimize bytes.translate() by deferring change detection
Move the equality check out of the hot loop to allow better compiler
optimization. Instead of checking each byte during translation, perform
a single memcmp at the end to determine if the input can be returned
unchanged.
This allows compilers to unroll and pipeline the loops, resulting in ~2x
throughput improvement for medium-to-large inputs (tested on an AMD zen2).
No change observed on small inputs.
It will also be faster for bytes subclasses as those do not need change
detection.
Serhiy Storchaka [Thu, 22 Jan 2026 12:29:13 +0000 (14:29 +0200)]
gh-67041: Allow to distinguish between empty and not defined URI components (GH-123305)
Changes in the urllib.parse module:
* Add option missing_as_none in urlparse(), urlsplit() and urldefrag(). If
it is true, represent not defined components as None instead of an
empty string.
* Add option keep_empty in urlunparse() and urlunsplit(). If it is
true, keep empty non-None components in the resulting string.
Mark Shannon [Thu, 22 Jan 2026 10:55:49 +0000 (10:55 +0000)]
GH-139109: Partial reworking of JIT data structures (GH-144105)
* Halve size of buffers by reusing combined trace + optimizer buffers for TOS caching
* Add simple buffer struct for more maintainable handling of buffers
* Decouple JIT structs from thread state struct
* Ensure terminator is added to trace, when optimizer gives up
Serhiy Storchaka [Wed, 21 Jan 2026 07:41:58 +0000 (09:41 +0200)]
gh-125346: Deprecate accepting standard Base64 alphabet when alternative alphabet is used (GH-141128)
Emit a warning in base64.urlsafe_b64decode() and base64.b64decode() when
the "+" or "/" characters occur in the Base64 data with alternative
alphabet if they are not the part of the alternative alphabet.
It is a DeprecationWarning in the strict mode (will be error) and
a FutureWarning in non-strict mode (will be ignored).
Neil Schemenauer [Tue, 20 Jan 2026 18:01:09 +0000 (10:01 -0800)]
gh-144054: no deferred refcount for untracked (gh-144081)
This reverts gh-144055 and fixes the bug in a different way. Deferred
reference counting relies on the object being tracked by the GC,
otherwise the object will live until interpreter shutdown. So, take
care that we do not enable deferred reference counting for objects that
are untracked. Also, if a tuple has deferred reference counting
enabled, don't untrack it.
Neil Schemenauer [Tue, 20 Jan 2026 13:45:12 +0000 (05:45 -0800)]
gh-144054: shutdown fix for deferred ref counting (GH-144055)
When shutting down, disable deferred refcounting for all GC objects. It
is important to do this also for untracked objects, which before this
change were getting missed.
Small code cleanup:
We can remove the shutdown case disable_deferred_refcounting() call
inside scan_heap_visitor() if we are careful about it. The key is
that frame_disable_deferred_refcounting() might fail if the object
is untracked.
Terry Jan Reedy [Tue, 20 Jan 2026 09:07:29 +0000 (04:07 -0500)]
gh-143774 - Improve IDLE Format Paragraph doc (#143775)
Add a reminder to not rewrap code line to the Menu => Format => Reformat Paragraph entry.
In Editing and Nagivagion, add a new 'Format block' subsection that defines 'paragraph'
to better match what is dependably handled as more or less expected.
In particular, specify equal indents and that the resulting indent equals original indent.
Also mention that selections are expanded to complete lines and how to modify max length.
(Also fix a couple case errors in cross references.)
gh-143935: Email preserve parens when folding comments (#143936)
Fix a bug in the folding of comments when flattening an email message
using a modern email policy. Comments consisting of a very long sequence of
non-foldable characters could trigger a forced line wrap that omitted the
required leading space on the continuation line, causing the remainder of
the comment to be interpreted as a new header field. This enabled header
injection with carefully crafted inputs.