Commit graph

56452 commits

Author SHA1 Message Date
Serhiy Storchaka
f73d2e7003
gh-144386: Add support for descriptors in ExitStack and AsyncExitStack (#144420)
__enter__(), __exit__(), __aenter__(), and __aexit__() can now be
arbitrary descriptors, not only normal methods, for consistency with the
"with" and "async with" statements.
2026-02-04 13:20:18 +02:00
Sam Gross
7e2c9bdc98
gh-120321: Add gi_state, cr_state, and ag_state attributes (gh-144409)
Add `gi_state`, `cr_state`, and `ag_state` attributes to generators,
coroutines, and async generators respectively. These attributes return the
current state as a string (e.g., `GEN_RUNNING`, `CORO_SUSPENDED`).

The `inspect.getgeneratorstate()`, `inspect.getcoroutinestate()`, and
`inspect.getasyncgenstate()` functions now return these attributes directly.

This is in preparation for making `gi_frame` thread-safe, which may involve
stop-the-world synchronization. The new state attributes avoid potential
performance cliffs in `inspect.getgeneratorstate()` and similar functions by
not requiring frame access.

Also removes unused `FRAME_COMPLETED` state and renumbers the frame state enum
to start at 0 instead of -1.
2026-02-03 13:06:32 -05:00
Taneli Hukkinen
bb917d83b1
gh-142956: Update tomllib to parse TOML 1.1.0 (#144243)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-02-03 13:41:57 +01:00
AN Long
3abc03c808
gh-132888: Fix Windows API error checking in pyrepl.windows_console (#144248) 2026-02-03 13:25:29 +01:00
Malcolm Smith
cb1dc91dcb
gh-144415: Android testbed fixes (#142912)
Modifies handling of `.gz` files in Android app payloads, and ensures that
when the Android testbed streams logs, stream flushes aren't treated as
newlines. This improves the output of test suites that use "one dot per test"
progress indicators.
2026-02-03 16:37:34 +08:00
Serhiy Storchaka
29acc08c8d
gh-75572: Speed up test_xpickle (GH-144393)
Run a long living subprocess which handles multiple requests instead of
running a new subprocess for each request.
2026-02-02 20:00:12 +02:00
Hai Zhu
89e6607e05
gh-139109: Replace _CHECK_STACK_SPACE with _CHECK_STACK_SPACE_OPERAND in JIT optiimizer (GH-144394) 2026-02-02 17:12:01 +00:00
AN Long
39f16a93ef
gh-142555: Fix null pointer dereference in array.__setitem__ via re-entrant __index__ (GH-142713) 2026-02-02 15:44:08 +01:00
Serhiy Storchaka
c3b61ef73d
gh-144001: Simplify Base64 decoding with altchars and ignorechars specified (GH-144324)
Treat "+" and "/" like other characters not in the alternative Base64
alphabet when both altchars and ignorechars are specified.
E.g. discard them if they are not in altchars but are in ignorechars,
and set error if they are not in altchars and not in ignorechars.
Only emit warnings if ignorechars is not specified.
2026-02-02 13:38:32 +02:00
Sergey B Kirpichev
15c9f2491d
gh-115231: Fill __module__ for built-in staticmethods (#115232)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-02-02 12:34:02 +01:00
Serhiy Storchaka
18347417b0
gh-143904: Raise OverflowError instead of IndexError for too large offset in struct.pack_into() (GH-143905) 2026-02-01 15:25:59 +02:00
Jelle Zijlstra
b6256014be
gh-144348: annotationlib: fix test that relies on set ordering (#144359) 2026-01-31 20:05:46 -08:00
adam j hartz
ccbe41e27c
gh-143055: Implementation of PEP 798 (#143056)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-01-30 20:37:52 -08:00
Pablo Galindo Salgado
96e4cd698a
gh-144319: Fix huge page safety in pymalloc arenas (#144331)
The pymalloc huge page support had two problems. First, on
architectures where the default huge page size exceeds the arena
size (e.g. 32 MiB on PPC, 512 MiB on ARM64 with 64 KB base
pages), mmap with MAP_HUGETLB silently allocates a full huge page
even when the requested size is smaller. The subsequent munmap
with the original arena size then fails with EINVAL, permanently
leaking the entire huge page. Second, huge pages were always
attempted when compiled in, with no way to disable them at
runtime. On Linux, if the huge page pool is exhausted, page
faults including copy-on-write faults after fork deliver SIGBUS
and kill the process.

The arena allocator now queries the system huge page size from
/proc/meminfo and skips MAP_HUGETLB when the arena size is not a
multiple of it. Huge pages also now require explicit opt-in at
runtime via the PYTHON_PYMALLOC_HUGEPAGES environment variable,
which is read through PyConfig and respects -E and -I flags.
The config field pymalloc_hugepages is propagated to the runtime
allocators struct so the low-level arena allocator can check it
without calling getenv directly.
2026-01-30 18:18:56 +00:00
Sam Gross
a01694dacd
gh-120321: Make gi_yieldfrom thread-safe in free-threading build (#144292)
Add a FRAME_SUSPENDED_YIELD_FROM_LOCKED state that acts as a brief
lock, preventing other threads from transitioning the frame state
while gen_getyieldfrom reads the yield-from object off the stack.
2026-01-30 12:20:27 -05:00
Sam Gross
e666a01ef4
gh-144295: Fix data race in dict method lookup and global load (gh-144312)
In `_PyDict_GetMethodStackRef`, only use the fast-path unicode lookup
when the dict is owned by the current thread or already marked as shared.
This prevents a race between the lookup and concurrent dict resizes,
which may free the PyDictKeysObject (i.e., it ensures that the resize
uses QSBR).

Address a similar issue in `_Py_dict_lookup_threadsafe_stackref` by
calling `ensure_shared_on_read()`.
2026-01-30 11:14:10 -05:00
Maurycy Pawłowski-Wieroński
be4ee8ee42
gh-144342: Use time.sleep in profiling.sampling (#144343) 2026-01-30 15:13:21 +00:00
Divyanshu Choudhury
5f57f6970b
gh-143423: Fix free-threaded build detection in sampling profiler (#143426) 2026-01-30 00:35:30 +00:00
Yongtao Huang
14c5339a38
Test: fix stale uops usage in test_capi/test_opt.py (GH-144239)
Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
2026-01-29 17:08:14 +00:00
Serhiy Storchaka
92c0ec2b00
gh-144264: Speed up Base64 decoding of data containing ignored characters (GH-144265)
Try the fast path again after decoding a quad the slow path.
Use a bitmap cache for the ignorechars argument.
2026-01-29 17:33:10 +02:00
Giampaolo Rodola
9b154aba7d
gh-83069: Use efficient event-driven subprocess.Popen.wait() on Linux / macOS / BSD (#144047) 2026-01-28 15:04:40 +01:00
Pieter Eendebak
08d7bd28fe
gh-140232: Do not track frozenset objects with immutables (#140234)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-01-28 11:27:37 +01:00
Romuald Brunet
1a637b29aa
gh-144249: Report filename in SSLContext.load_cert_chain errors (#144250)
When user tries to load a certificate chain, attach the related
filename to the exception being raised. Improving user experience.

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-01-28 11:20:51 +01:00
Sam Gross
6ea3f8cd7f
gh-144289: Remove ENABLE_SPECIALIZATION_FT (gh-144290)
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.
2026-01-27 17:52:50 -05:00
Diego Russo
66055d0650
GH-126910: add test for manual frame unwinding (#144137) 2026-01-27 13:17:40 +00:00
Stefano Rivera
197e4c0628
Avoid TestNullDlsym hanging on HP-PA (#141011)
glibc has no support for IFUNC on HP PA RISC yet. Rather than waiting
for an "OK" that we'll never get, skip the test.

See: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/hppa/dl-irel.h;h=770dcb3ea3a6ce232bb11bf59315cfec4c543f93;hb=HEAD
2026-01-27 12:39:03 +01:00
Stefano Rivera
17d447e993
gh-126014: test_makefile_test_folders: Ignore basically-empty directories (#140466)
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.
2026-01-27 11:05:09 +01:00
Serhiy Storchaka
7febbe6b60
gh-144001: Support ignorechars in binascii.a2b_base64() and base64.b64decode() (GH-144024) 2026-01-26 20:11:40 +02:00
Jeong, YunWon
9181d776da
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>
2026-01-26 17:40:56 +01:00
Jake Lishman
19de10d3d8
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.
2026-01-26 16:45:17 +01:00
FooIbar
1f55caf97e
gh-144212: Add image/jxl to mimetypes (GH-144213) 2026-01-26 15:26:55 +01:00
VanshAgarwal24036
8f459255eb
gh-144100: Fix crash for POINTER(str) used in ctypes argtypes (#144108)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-01-26 13:27:42 +01:00
Priyanshu Singh
decb25e8f0
gh-144128: Fix crash in array.fromlist with reentrant __index__ (#144138)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-01-26 13:13:49 +01:00
Jelle Zijlstra
639c1ad4f1
gh-144169: Fix three crashes in AST objects with non-str kwargs (#144178)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-01-25 17:28:58 -08:00
benediktjohannes
76d3ae71ba
gh-144217: Add dicom support (medical imaging) to mimetypes (GH-144218)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2026-01-25 22:22:43 +00:00
AN Long
6e55337f8a
gh-143995: Eliminate redundant refcounting in the JIT from LOAD_ATTR_MODULE (GH-143996) 2026-01-25 18:24:44 +00:00
Yashraj
a51bf70f95
gh-143504: Expose CELL status of a symbol in symtable (#143549) 2026-01-25 15:21:27 +00:00
Yi Yang
979d92fefc
gh-144140: Optimize len for string constants in optimizer (GH-144142) 2026-01-24 16:09:29 +00:00
Serhiy Storchaka
012c498035
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.
2026-01-24 11:13:50 +00:00
reiden
6d972e0104
gh-130415: Narrow types to constants in branches involving specialized comparisons with a constant (GH-144150) 2026-01-24 10:02:08 +00:00
Hai Zhu
29840247ff
gh-144068: fix JIT tracer memory leak when daemon thread exits (GH-144077) 2026-01-24 09:43:01 +00:00
AN Long
4e10fa993a
gh-144007: Eliminate redundant refcounting in the JIT for BINARY_OP (GH-144011) 2026-01-24 09:35:32 +00:00
Terry Jan Reedy
29f1e778fa
gh-135142: Initial 3.15 IDLE News3.txt entries (#144200) 2026-01-23 21:34:41 -05:00
Zachary Ware
58ccf21cbb
gh-74902: Avoid hitting unicode.org for test data (GH-144195)
Use our own pythontest.net instead.
2026-01-23 15:07:27 -06:00
Serhiy Storchaka
25a10b60b0
gh-144027: Fix documentation for ignorechars in base64.a85decode() (GH-144028)
It does not support an ASCII string.

Also add more tests.
2026-01-23 20:55:48 +02:00
AN Long
2f42f83344
gh-144005: Eliminate redundant refcounting in the JIT for BINARY_OP_EXTEND (#144006) 2026-01-23 17:19:01 +00:00
Seth Michael Larson
052e55e7d4
gh-144125: email: verify headers are sound in BytesGenerator
Co-authored-by: Denis Ledoux <dle@odoo.com>
Co-authored-by: Denis Ledoux <5822488+beledouxdenis@users.noreply.github.com>
Co-authored-by: Petr Viktorin <302922+encukou@users.noreply.github.com>
Co-authored-by: Bas Bloemsaat <1586868+basbloemsaat@users.noreply.github.com>
2026-01-23 14:59:35 +00:00
Serhiy Storchaka
c5cfcdf16a
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.
2026-01-22 14:29:13 +02:00
Jeong, YunWon
67535ab2d2
gh-143001: Add @cpython_only to test_sys.test_current_frames() (#144004) 2026-01-22 12:08:08 +01:00
Jeong, YunWon
c447d1bc14
gh-143959: Make _datetime optional for test_sys (GH-144003) 2026-01-22 12:52:16 +02:00