Commit graph

130105 commits

Author SHA1 Message Date
Mark Shannon
b53fc7caa6
GH-144179: Use recorded values to make optimizer more robust (GH-144437)
* Add three new symbol kinds
* Do not smuggle code object in _PUSH_FRAME operand
* Fix small bug in predicate analysis
2026-02-05 08:58:41 +00:00
Raymond Hettinger
b6d8aa436b
Itertools recipes: Replace the tabulate() example with running_mean() (gh-144483) 2026-02-04 14:21:20 -06:00
Pieter Eendebak
009c8c052f
gh-123471: Make concurrent iteration over itertools.permutations and itertools.combinations_with_replacement thread-safe (gh-144402) 2026-02-04 13:38:45 -05:00
Serhiy Storchaka
dd0fde58cc
gh-143962: Improve name suggestions for not normalized names (GH-144154)
Suggest the normalized name or the closest name to the normalized name.
If the suggested name is not ASCII, include also its ASCII representation.
2026-02-04 17:23:09 +00:00
Adorilson Bezerra
1b6d737ee0
gh-106318: Add examples for str.startswith() method (#144369)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-02-04 18:17:42 +01:00
Peter Bierma
914fbec214
gh-141004: Document remaining pyport.h utility macros (GH-144279)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-02-04 11:43:47 -05:00
Petr Viktorin
e423e0c2cc
gh-141984: Reword and reorganize Subscription (and Slicing) docs (GH-141985)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-02-04 16:08:23 +00:00
Victor Stinner
2aea861fe0
gh-140824: Fix _Py_DumpExtensionModules() to ignore sub-modules (#144339)
Ignore "math.integer" extension if "math" is in
sys.stdlib_module_names.
2026-02-04 16:06:35 +01:00
Lucas Colley
0bb4ecafcb
gh-142903: add conda-forge license for pixi-packages (#143468)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: h-vetinari <h.vetinari@gmx.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-02-04 12:36:14 +00:00
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
kovan
34e5a63f14
gh-141444: Replace dead URL in urllib.robotparser example (GH-144443)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:45:15 +02:00
Guido Imperiale
37c35542a9
gh-143120: pixi builds for free-threading and TSAN (#142872)
Co-authored-by: Isuru Fernando <isuruf@gmail.com>
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
2026-02-04 09:58:29 +05:30
Max Bachmann
9d0c7432ea
Remove unused PYEXPAT_EXPORTS from PCBuild/pyexpat.vcxproj (GH-144462) 2026-02-03 23:38:22 +00: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
Sam Gross
79c43e7c24
gh-139103: Use borrowed references for positional args in _PyStack_UnpackDict (gh-144407)
The positional arguments passed to _PyStack_UnpackDict are already
kept alive by the caller, so we can avoid the extra reference count
operations by using borrowed references instead of creating new ones.

This reduces reference count contention in the free-threaded build
when calling functions with keyword arguments. In particular, this
avoids contention on the type argument to `__new__` when instantiating
namedtuples with keyword arguments.
2026-02-03 12:24:35 -05:00
AN Long
53fecbe6e1
gh-127313: Use getLogger() without argument to get root logger in logging cookbook (GH-143683)
Use getLogger() to get root logger in logging cookbook
2026-02-03 15:49:12 +01:00
Seth Michael Larson
4e15b8d95d
gh-74453: Add stronger security warning to os.path.commonprefix (GH-144401) 2026-02-03 15:07:59 +01:00
Adorilson Bezerra
45d00a0791
gh-106318: Add examples for str.rindex() method (#143887)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-02-03 13:29:05 +00: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
Thomas Kluyver
74c1f4145e
gh-144377: Clean up sqlite3 Connection's list of weakrefs to Cursor objects (#144378) 2026-02-03 13:36:12 +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
Sam Gross
93b27e7f6d
gh-139103: use METH_FASTCALL for tp_new_wrapper (#144406) 2026-02-03 16:02:06 +05:30
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
Mark Shannon
141fd8b894
GH-144179: Add value recording to JIT tracing front-end (GH-144303) 2026-02-02 16:57:04 +00:00
Seth Michael Larson
5f91577cdd
gh-144376: Only run 'address' fuzzer for python3-libraries (#144398) 2026-02-02 17:55:11 +02:00
Stan Ulbrych
a447828565
gh-144242: Note that issues aren't needed for typos in docs template (GH-144288) 2026-02-02 14:56:45 +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
Petr Viktorin
afc2aeb850
gh-134160: "First extension module" tutorial improvements (GH-144183)
- Pass -v to pip, so compiler output is visible
- Move the call ``spam.system(3)`` up so that error handling is tested
  right after it's added
- Use `PyUnicode_AsUTF8AndSize` as `PyUnicode_AsUTF8` is not in the
  Limited API.
- Add a footnote about embedded NULs.
2026-02-02 15:32:25 +01:00
Hai Zhu
ebbb2ca81f
gh-144145: Revert PR#144122 for performance and potential bugs. (GH-144391)
Revert "gh-144145: Track nullness of properties in the Tier 2 JIT optimizer (GH-144122)"

This reverts commit 1dc12b2883.
2026-02-02 14:09:54 +00: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
Guilherme Leobas
092ef634f5
docs: update dangling reference to LOAD_METHOD in dis.rst (#144358) 2026-02-02 16:00:17 +05:30
Ruiyang Ke
40d07cad38
gh-144380: Fix incorrect type check in buffered_iternext() (#144381) 2026-02-02 15:34:18 +05:30
Peter Bierma
3a0e183556
gh-144277: Fix usage of free-threaded terminology in the documentation (GH-144333) 2026-02-01 20:39:26 -05: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
AN Long
db61f622c6
Fix unused variable 'COLORS' warning in optimizer.c (#144373) 2026-02-01 04:01:45 +00: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
reiden
a7048327ed
gh-144280: Add missing predicate symbol to case-switch (GH-144298) 2026-01-30 16:43:27 +00: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
Hai Zhu
1dc12b2883
gh-144145: Track nullness of properties in the Tier 2 JIT optimizer (GH-144122) 2026-01-30 15:25:19 +00: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
Pieter Eendebak
1b08143466
gh-143192 Avoid incref/decref pair in long_bitwise (gh-143194)
Remove unnecessary reference count operations in long_bitwise in order to
avoid reference count contention in the free-threading build.
2026-01-29 16:32:09 -05:00
Yongtao Huang
219b7ac9d5
gh-144307: Fix a reference leak during module teardown (GH-144308)
Signed-off-by: Yongtao Huang <yongtaoh2022@gamil.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-01-29 13:50:54 -05: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