]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
8 months agogh-130954: Fix multiprocessing test_notify_n (#130955)
Sam Gross [Sat, 8 Mar 2025 18:04:30 +0000 (13:04 -0500)] 
gh-130954: Fix multiprocessing test_notify_n (#130955)

The test could deadlock trying join on the worker processes.
Apply the same technique as gh-130933.

Join the process before the test ends in `test_notify` as well.

8 months agogh-128646: Implement GzipFile.readinto[1]() methods (GH-128647)
Chris Markiewicz [Sat, 8 Mar 2025 03:04:45 +0000 (22:04 -0500)] 
gh-128646: Implement GzipFile.readinto[1]() methods (GH-128647)

The new methods simply delegate to the underlying buffer, much like the existing GzipFile.read[1] methods.  This avoids extra allocations caused by the BufferedIOBase.readinto implementation previously used.

This commit also factors out a common readability check rather than copying it an additional two times.

8 months agogh-130917: update timer and workload in test_signal (#130918)
Diego Russo [Fri, 7 Mar 2025 21:10:02 +0000 (21:10 +0000)] 
gh-130917: update timer and workload in test_signal (#130918)

The workload to advance the virtual timeout is too lightweight for some
platforms. As result the test goes in timeout as it never reaches the
end of the timer. By having a heavier workload, the virtual timer
advances rapidly and the SIGVTALRM is sent before the timeout.

8 months agogh-117151: IO performance improvement, increase io.DEFAULT_BUFFER_SIZE to 128k (GH...
morotti [Fri, 7 Mar 2025 19:36:12 +0000 (19:36 +0000)] 
gh-117151: IO performance improvement, increase io.DEFAULT_BUFFER_SIZE to 128k (GH-118144)

Co-authored-by: rmorotti <romain.morotti@man.com>
8 months agoGH-128520: Merge `pathlib._local` into `pathlib` (#130748)
Barney Gale [Fri, 7 Mar 2025 19:24:57 +0000 (19:24 +0000)] 
GH-128520: Merge `pathlib._local` into `pathlib` (#130748)

The `pathlib` module used to import stuff from both `_abc` and `_local`,
but nowadays the `_local` module provides the entire public pathlib
implementation, so there's no reason for the indirection.

8 months agogh-130851: Only intern constants of types generated by the compiler (#130901)
Sam Gross [Fri, 7 Mar 2025 15:34:53 +0000 (10:34 -0500)] 
gh-130851: Only intern constants of types generated by the compiler (#130901)

The free-threading build interns and immortalizes most constants
generated by the bytecode compiler. However, users can construct their
own code objects with arbitrary constants. We should not intern or
immortalize these objects if they are not of a type that we know how to
handle.

This change fixes a reference leak failure in the recently added
`test_code.test_unusual_constants` test. It also addresses a potential
crash that could occur when attempting to destroy an immortalized
object during interpreter shutdown.

8 months agogh-110206: Fix multiprocessing test_notify_all (#130933)
Sam Gross [Fri, 7 Mar 2025 14:58:09 +0000 (09:58 -0500)] 
gh-110206: Fix multiprocessing test_notify_all (#130933)

The test could deadlock trying join on the worker processes due to a
combination of behaviors:

* The use of `assertReachesEventually` did not ensure that workers
  actually woken.release() because the SyncManager's Semaphore does not
  implement get_value.

* This mean that the test could finish and the variable "sleeping" would
  got out of scope and be collected. This unregisters the proxy leading
  to failures in the worker or possibly the manager.

* The subsequent call to `p.join()` during cleanUp therefore never
  finished.

This takes two approaches to fix this:

1) Use woken.acquire() to ensure that the workers actually finish
   calling woken.release()

2) At the end of the test, wait until the workers are finished, while `cond`,
   `sleeping`, and `woken` are still valid.

8 months agoGH-128534: Fix behavior of branch monitoring for `async for` (GH-130847)
Mark Shannon [Fri, 7 Mar 2025 14:30:31 +0000 (14:30 +0000)] 
GH-128534: Fix behavior of branch monitoring for `async for` (GH-130847)

* Both branches in a pair now have a common source and are included in co_branches

8 months agoCorrect function name in `Doc/extending/embedding.rst` (#127539)
Boris Verkhovskiy [Fri, 7 Mar 2025 13:06:36 +0000 (06:06 -0700)] 
Correct function name in `Doc/extending/embedding.rst` (#127539)

8 months agogh-130932: Fix incorrect exception handling in _PyModule_IsPossiblyShadowing (#130934)
Shantanu [Fri, 7 Mar 2025 07:41:28 +0000 (23:41 -0800)] 
gh-130932: Fix incorrect exception handling in _PyModule_IsPossiblyShadowing (#130934)

I chose to not raise an exception here because I think it would be
confusing for module attribute access to start raising something other
than AttributeError if e.g. the cwd goes away

Without the change in moduleobject.c
```
./python.exe -m unittest test.test_import.ImportTests.test_script_shadowing_stdlib_cwd_failure
...
Assertion failed: (PyErr_Occurred()), function _PyObject_SetAttributeErrorContext, file object.c, line 1253.
```

8 months agogh-130893: Fix typo in SqliteInteractiveConsole.runsource docstring (#130894)
scotscotmcc [Fri, 7 Mar 2025 06:10:37 +0000 (00:10 -0600)] 
gh-130893: Fix typo in SqliteInteractiveConsole.runsource docstring (#130894)

8 months agogh-129011: Update comments in FileIO to match current code (#129012)
Cody Maloney [Fri, 7 Mar 2025 01:18:22 +0000 (17:18 -0800)] 
gh-129011: Update comments in FileIO to match current code (#129012)

8 months agogettext: Remove outdated "TODO" comment (#130890)
Stan Ulbrych [Thu, 6 Mar 2025 23:41:03 +0000 (23:41 +0000)] 
gettext: Remove outdated "TODO" comment (#130890)

8 months agogh-130920: Fix data race in STORE_SUBSCR_LIST_INT (#130923)
Sam Gross [Thu, 6 Mar 2025 20:59:48 +0000 (15:59 -0500)] 
gh-130920: Fix data race in STORE_SUBSCR_LIST_INT (#130923)

The write of the item to the list needs to use an atomic operation in
the free threading build.

Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
8 months agogh-118331: Fix `test_list.ListTest.test_no_memory` under trace refs build (#130921)
mpage [Thu, 6 Mar 2025 20:11:50 +0000 (12:11 -0800)] 
gh-118331: Fix `test_list.ListTest.test_no_memory` under trace refs build (#130921)

Fix `test_list.ListTest.test_no_memory` under trace refs build

Memory allocation ends up failing in _PyRefchainTrace(), which produces
different output. Assert that we don't segfault, which is the thing
we want to test and is less brittle than checking output.

8 months agogh-128364: Fix flaky `test_concurrent_futures.test_wait` tests (gh-130742)
Sam Gross [Thu, 6 Mar 2025 17:30:58 +0000 (12:30 -0500)] 
gh-128364: Fix flaky `test_concurrent_futures.test_wait` tests (gh-130742)

Use events instead of relying on `time.sleep()`. The tests are also now about
four times faster.

8 months agogh-124878: Fix race conditions during interpreter finalization (#130649)
Sam Gross [Thu, 6 Mar 2025 15:38:34 +0000 (10:38 -0500)] 
gh-124878: Fix race conditions during interpreter finalization (#130649)

The PyThreadState field gains a reference count field to avoid
issues with PyThreadState being a dangling pointer to freed memory.
The refcount starts with a value of two: one reference is owned by the
interpreter's linked list of thread states and one reference is owned by
the OS thread. The reference count is decremented when the thread state
is removed from the interpreter's linked list and before the OS thread
calls `PyThread_hang_thread()`. The thread that decrements it to zero
frees the `PyThreadState` memory.

The `holds_gil` field is moved out of the `_status` bit field, to avoid
a data race where on thread calls `PyThreadState_Clear()`, modifying the
`_status` bit field while the OS thread reads `holds_gil` when
attempting to acquire the GIL.

The `PyThreadState.state` field now has `_Py_THREAD_SHUTTING_DOWN` as a
possible value. This corresponds to the `_PyThreadState_MustExit()`
check. This avoids race conditions in the free threading build when
checking `_PyThreadState_MustExit()`.

8 months agogh-127647: Add typing.Reader and Writer protocols (#127648)
Sebastian Rittau [Thu, 6 Mar 2025 15:36:19 +0000 (16:36 +0100)] 
gh-127647: Add typing.Reader and Writer protocols (#127648)

8 months agogh-128563: Clarify wording in Whats new for Tail call (#130911)
Ken Jin [Thu, 6 Mar 2025 13:38:05 +0000 (21:38 +0800)] 
gh-128563: Clarify wording in Whats new for Tail call (#130911)

Clarify wording in Whats new for Tail call

8 months agogh-130860: Fix width calculation, when separators in fractional part (GH-130865)
Sergey B Kirpichev [Thu, 6 Mar 2025 12:26:29 +0000 (15:26 +0300)] 
gh-130860: Fix width calculation, when separators in fractional part (GH-130865)

This amends f39a07be47

8 months agoGH-130903: typo in optimizer DSL for _GUARD_BOTH_UNICODE (#130904)
Jamie Phan [Thu, 6 Mar 2025 11:11:08 +0000 (22:11 +1100)] 
GH-130903: typo in optimizer DSL for _GUARD_BOTH_UNICODE (#130904)

Typo introduced in gh-118910.

8 months agogh-130574: renumber RESUME opcode from 149 to 128 (GH-130685)
Tomasz Pytel [Thu, 6 Mar 2025 08:59:36 +0000 (03:59 -0500)] 
gh-130574: renumber RESUME opcode from 149 to 128 (GH-130685)

8 months agogh-128563: Add correction note to tail call in whats new (#130908)
Ken Jin [Thu, 6 Mar 2025 06:43:53 +0000 (14:43 +0800)] 
gh-128563: Add correction note to tail call in whats new (#130908)

* Add correction note to tail call in whats new

* Update 3.14.rst

8 months agogh-85795: Raise a clear error when `super()` is used in `typing.NamedTuple` subclasse...
Bartosz Sławecki [Thu, 6 Mar 2025 04:45:47 +0000 (05:45 +0100)] 
gh-85795: Raise a clear error when `super()` is used in `typing.NamedTuple` subclasses (#130082)

8 months agogh-128041: Fix incorrect bullet placement in "What's new" (GH-130900)
Charles Machalow [Wed, 5 Mar 2025 22:59:56 +0000 (14:59 -0800)] 
gh-128041: Fix incorrect bullet placement in "What's new" (GH-130900)

8 months agoGH-130153: Reword the wildcard matching part of the tutorial (GH-129954)
Tshepang Mbambo [Wed, 5 Mar 2025 22:59:47 +0000 (00:59 +0200)] 
GH-130153: Reword the wildcard matching part of the tutorial (GH-129954)

8 months agogh-128041: Add `terminate_workers` and `kill_workers` methods to ProcessPoolExecutor...
Charles Machalow [Wed, 5 Mar 2025 22:31:42 +0000 (14:31 -0800)] 
gh-128041: Add `terminate_workers` and `kill_workers` methods to ProcessPoolExecutor (GH-130849)

This adds two new methods to `multiprocessing`'s `ProcessPoolExecutor`:
- **`terminate_workers()`**: forcefully terminates worker processes using `Process.terminate()`
- **`kill_workers()`**: forcefully kills worker processes using `Process.kill()`

These methods provide users with a direct way to stop worker processes without `shutdown()` or relying on implementation details, addressing situations where immediate termination is needed.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Sam Gross @colesbury
Commit-message-mostly-authored-by: Claude Sonnet 3.7 (because why not -greg)
8 months agogh-129964: Fix JIT crash on Windows on Arm (GH-130882)
Diego Russo [Wed, 5 Mar 2025 20:40:50 +0000 (20:40 +0000)] 
gh-129964: Fix JIT crash on Windows on Arm (GH-130882)

8 months agoGH-115802: JIT using the "medium" code model on x86_64-unknown-linux-gnu (GH-130097)
Brandt Bucher [Wed, 5 Mar 2025 19:54:33 +0000 (11:54 -0800)] 
GH-115802: JIT using the "medium" code model on x86_64-unknown-linux-gnu (GH-130097)

8 months agogh-118331: Fix a couple of issues when list allocation fails (#130811)
mpage [Wed, 5 Mar 2025 18:42:09 +0000 (10:42 -0800)] 
gh-118331: Fix a couple of issues when list allocation fails (#130811)

* Fix use after free in list objects

Set the items pointer in the list object to NULL after the items array
is freed during list deallocation. Otherwise, we can end up with a list
object added to the free list that contains a pointer to an already-freed
items array.

* Mark `_PyList_FromStackRefStealOnSuccess` as escaping

I think technically it's not escaping, because the only object that
can be decrefed if allocation fails is an exact list, which cannot
execute arbitrary code when it is destroyed. However, this seems less
intrusive than trying to special cases objects in the assert in `_Py_Dealloc`
that checks for non-null stackpointers and shouldn't matter for performance.

8 months agogh-130878: Add extra check to prepare_ssl.py (GH-130879)
Burkov Egor [Wed, 5 Mar 2025 17:08:30 +0000 (20:08 +0300)] 
gh-130878: Add extra check to prepare_ssl.py (GH-130879)

8 months agoUpdate links from typing.readthedocs.io to typing.python.org (#130877)
Sebastian Rittau [Wed, 5 Mar 2025 15:26:44 +0000 (16:26 +0100)] 
Update links from typing.readthedocs.io to typing.python.org (#130877)

8 months agogh-130851: Don't crash when deduping unusual code constants (#130853)
Sam Gross [Wed, 5 Mar 2025 14:04:49 +0000 (09:04 -0500)] 
gh-130851: Don't crash when deduping unusual code constants (#130853)

The bytecode compiler only generates a few different types of constants,
like str, int, tuple, slices, etc. Users can construct code objects with
various unusual constants, including ones that are not hashable or not
even constant.

The free threaded build previously crashed with a fatal error when
confronted with these constants. Instead, treat distinct objects of
otherwise unhandled types as not equal for the purposes of deduplication.

8 months agoGH-127705: better double free message. (GH-130785)
Mark Shannon [Wed, 5 Mar 2025 14:00:42 +0000 (14:00 +0000)] 
GH-127705: better double free message. (GH-130785)

* Add location information when accessing already closed stackref

* Add #def option to track closed stackrefs to provide precise information for use after free and double frees.

8 months agogh-127750: Improve repr of functools.singledispatchmethod (GH-130220)
Serhiy Storchaka [Wed, 5 Mar 2025 11:10:05 +0000 (13:10 +0200)] 
gh-127750: Improve repr of functools.singledispatchmethod (GH-130220)

8 months agogh-116742: Fix subprocess test_check_output_timeout() (#130836)
Victor Stinner [Wed, 5 Mar 2025 10:51:33 +0000 (11:51 +0100)] 
gh-116742: Fix subprocess test_check_output_timeout() (#130836)

Fix a race condition in test_check_output_timeout() of
test_subprocess. Don't write into stdout anymore, since there is no
reliable way to synchronize the parent and the child processes.

Change the timeout from 3 seconds to 0.1 seconds, and remove
@requires_resource('walltime') decorator.

8 months agogh-130824: Clean up test wrappers for PyLong_*AndOverflow functions (GH-130871)
Serhiy Storchaka [Wed, 5 Mar 2025 10:50:53 +0000 (12:50 +0200)] 
gh-130824: Clean up test wrappers for PyLong_*AndOverflow functions (GH-130871)

8 months agogh-130824: Add tests for `NULL` in `PyLong_*AndOverflow` functions (GH-130828)
Peter Bierma [Wed, 5 Mar 2025 08:58:39 +0000 (03:58 -0500)] 
gh-130824: Add tests for `NULL` in `PyLong_*AndOverflow` functions (GH-130828)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
8 months agoGH-125722: Increase minimum supported Sphinx to 8.2.0 (#130444)
Adam Turner [Wed, 5 Mar 2025 00:31:01 +0000 (00:31 +0000)] 
GH-125722: Increase minimum supported Sphinx to 8.2.0 (#130444)

8 months agogh-130794: Process interpreter QSBR queue in _PyMem_AbandonDelayed. (gh-130808)
Sam Gross [Tue, 4 Mar 2025 23:04:04 +0000 (18:04 -0500)] 
gh-130794: Process interpreter QSBR queue in _PyMem_AbandonDelayed. (gh-130808)

This avoids a case where the interpreter's queue of memory to be freed
could grow rapidly if there are many short lived threads.

8 months agogh-127371 Avoid unbounded growth SpooledTempfile.writelines (GH-127372)
Bert Peters [Tue, 4 Mar 2025 22:06:07 +0000 (23:06 +0100)] 
gh-127371 Avoid unbounded growth SpooledTempfile.writelines (GH-127372)

8 months agoGH-130415: Narrow str to "" based on boolean tests (GH-130476)
Amit Lavon [Tue, 4 Mar 2025 21:20:17 +0000 (13:20 -0800)] 
GH-130415: Narrow str to "" based on boolean tests (GH-130476)

8 months agogh-125377: Improve tab indentation for pdb multi-line input (#130471)
Tian Gao [Tue, 4 Mar 2025 20:45:38 +0000 (15:45 -0500)] 
gh-125377: Improve tab indentation for pdb multi-line input (#130471)

8 months agoGH-130415: Narrow int to 0 based on boolean tests (GH-130772)
Klaus117 [Tue, 4 Mar 2025 20:44:09 +0000 (12:44 -0800)] 
GH-130415: Narrow int to 0 based on boolean tests (GH-130772)

8 months agogh-130660: Add a test for pdb when user quits after interact command (#130852)
Tian Gao [Tue, 4 Mar 2025 20:10:32 +0000 (15:10 -0500)] 
gh-130660: Add a test for pdb when user quits after interact command (#130852)

8 months agogh-105499: Merge typing.Union and types.UnionType (#105511)
Jelle Zijlstra [Tue, 4 Mar 2025 19:44:19 +0000 (11:44 -0800)] 
gh-105499: Merge typing.Union and types.UnionType (#105511)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
8 months agogh-126085: Add `tp_iter` to TypeAliasType to allow star unpacking (#127981)
Tomas R. [Tue, 4 Mar 2025 19:34:59 +0000 (20:34 +0100)] 
gh-126085: Add `tp_iter` to TypeAliasType to allow star unpacking (#127981)

8 months agogh-130090: Support PGO for clang-cl on Windows (GH-129907)
Chris Eibl [Tue, 4 Mar 2025 19:29:03 +0000 (20:29 +0100)] 
gh-130090: Support PGO for clang-cl on Windows (GH-129907)

8 months agogh-130730: Fix multiprocessing test_active_children() (#130837)
Victor Stinner [Tue, 4 Mar 2025 17:05:20 +0000 (18:05 +0100)] 
gh-130730: Fix multiprocessing test_active_children() (#130837)

Replace a sleep with an event: sleep is not a reliable
synchronization primitive.

8 months agoGH-90916: Add helper function to dis.Instruction and use it to reduce churn in test_d...
Mark Shannon [Tue, 4 Mar 2025 16:43:39 +0000 (16:43 +0000)] 
GH-90916: Add helper function to dis.Instruction and use it to reduce churn in test_dis (GH-130643)

8 months agogh-82987: Stop on calling frame unconditionally for inline breakpoints (#130493)
Tian Gao [Tue, 4 Mar 2025 16:35:47 +0000 (11:35 -0500)] 
gh-82987: Stop on calling frame unconditionally for inline breakpoints (#130493)

8 months agoRevert "gh-128041: Add `terminate_workers` and `kill_workers` methods to ProcessPoolE...
Sam Gross [Tue, 4 Mar 2025 16:19:06 +0000 (11:19 -0500)] 
Revert "gh-128041: Add `terminate_workers` and `kill_workers` methods to ProcessPoolExecutor (GH-128043)" (#130838)

The test_concurrent_futures.test_process_pool test is failing in CI.

This reverts commit f97e4098ff71a6488fd3411f9f9e6fa7a7bb4efe.

8 months agogh-129567: Add a note to `typing.TypedDict` docs about name mangling (#130233)
sobolevn [Tue, 4 Mar 2025 15:15:00 +0000 (18:15 +0300)] 
gh-129567: Add a note to `typing.TypedDict` docs about name mangling (#130233)

8 months agogh-130727: Retry test_wmi on TimeoutError (#130832)
Victor Stinner [Tue, 4 Mar 2025 15:07:01 +0000 (16:07 +0100)] 
gh-130727: Retry test_wmi on TimeoutError (#130832)

Use sleeping_retry() in test_wmi to retry multiple times on
TimeoutError. Wait up to LONG_TIMEOUT seconds (5 minutes by default).

8 months agogh-128184: Fix display of signatures with ForwardRefs (#130815)
Jelle Zijlstra [Tue, 4 Mar 2025 14:58:37 +0000 (06:58 -0800)] 
gh-128184: Fix display of signatures with ForwardRefs (#130815)

Co-authored-by: sobolevn <mail@sobolevn.me>
8 months agogh-130547: Fix race between dict_dealloc and split_keys_entry_added (gh-130778)
Donghee Na [Tue, 4 Mar 2025 13:50:33 +0000 (22:50 +0900)] 
gh-130547: Fix race between dict_dealloc and split_keys_entry_added (gh-130778)

8 months agogh-129666: Add C11/C++11 to docs and -pedantic-errors to GCC/clang test_c[pp]ext...
Petr Viktorin [Tue, 4 Mar 2025 13:10:09 +0000 (14:10 +0100)] 
gh-129666: Add C11/C++11 to docs and -pedantic-errors to GCC/clang test_c[pp]ext tests (GH-130692)

Disable pedantic check for c++03 (unlimited API)

Also add a check for c++03 *limited* API, which passes in pedantic mode
after removing a comma in the `PySendResult` declaration, and allowing
`long long`.

8 months agogh-130736: Fix asyncio test_shutdown_default_executor_timeout() (#130800)
Victor Stinner [Tue, 4 Mar 2025 11:16:07 +0000 (12:16 +0100)] 
gh-130736: Fix asyncio test_shutdown_default_executor_timeout() (#130800)

Replace time.sleep() with threading.Event.

8 months agogh-89083: add support for UUID version 7 (RFC 9562) (#121119)
Bénédikt Tran [Tue, 4 Mar 2025 09:47:19 +0000 (10:47 +0100)] 
gh-89083: add support for UUID version 7 (RFC 9562) (#121119)

Add support for generating UUIDv7 objects according to RFC 9562, §5.7 [1].

The functionality is provided by the `uuid.uuid7()` function. The implementation
is based on a 42-bit counter as described by Method 1, §6.2 [2] and guarantees
monotonicity within the same millisecond.

[1]: https://www.rfc-editor.org/rfc/rfc9562.html#section-5.7
[2]: https://www.rfc-editor.org/rfc/rfc9562.html#section-6.2

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Éric <merwok@netwok.org>
8 months agogh-111178: Fix function signatures in structseq.c (#130683)
Victor Stinner [Tue, 4 Mar 2025 09:33:45 +0000 (10:33 +0100)] 
gh-111178: Fix function signatures in structseq.c (#130683)

8 months agogh-111178: Fix function signatures of unicodeiter (#130684)
Victor Stinner [Tue, 4 Mar 2025 09:33:09 +0000 (10:33 +0100)] 
gh-111178: Fix function signatures of unicodeiter (#130684)

8 months agogh-130149: fix HMAC tests for some FIPS-only build bots (#130788)
Bénédikt Tran [Tue, 4 Mar 2025 09:15:33 +0000 (10:15 +0100)] 
gh-130149: fix HMAC tests for some FIPS-only build bots (#130788)

Skips some HMAC tests for some FIPS-only build bots that do not have the underlying hash functions.

8 months agogh-130486: Fix test_venv fails from within venv (GH-130487)
Andrii Hrimov [Tue, 4 Mar 2025 07:48:07 +0000 (08:48 +0100)] 
gh-130486: Fix test_venv fails from within venv (GH-130487)

8 months agogh-130599: use static constants str-to-int conversion (gh-130714)
Neil Schemenauer [Tue, 4 Mar 2025 03:00:50 +0000 (19:00 -0800)] 
gh-130599: use static constants str-to-int conversion (gh-130714)

Avoid a data race in free-threaded builds due to mutating global arrays at
runtime.  Instead, compute the constants with an external Python script and
then define them as static global constant arrays.  These constants are
used by `long_from_non_binary_base()`.

8 months agogh-124445: Allow specializing generic ParamSpec aliases (#124512)
Tomas R. [Mon, 3 Mar 2025 22:58:33 +0000 (23:58 +0100)] 
gh-124445: Allow specializing generic ParamSpec aliases (#124512)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
8 months agogh-130790: Remove references about unicode's readiness from comments (#130801)
Sergey Miryanov [Mon, 3 Mar 2025 19:18:09 +0000 (00:18 +0500)] 
gh-130790: Remove references about unicode's readiness from comments (#130801)

8 months agogh-130737: Fix multiprocessing test_notify() (#130797)
Victor Stinner [Mon, 3 Mar 2025 18:45:26 +0000 (19:45 +0100)] 
gh-130737: Fix multiprocessing test_notify() (#130797)

Replace hardcoded delay (100 ms) with a loop awaiting until a
condition is true: replace assertReturnsIfImplemented() with
assertReachesEventually().

Use sleeping_retry() in assertReachesEventually() to tolerate slow
buildbots and raise an exception on timeout (30 seconds).

8 months agoGH-128520: Merge `pathlib._abc` into `pathlib.types` (#130747)
Barney Gale [Mon, 3 Mar 2025 17:56:57 +0000 (17:56 +0000)] 
GH-128520: Merge `pathlib._abc` into `pathlib.types` (#130747)

There used to be a meaningful distinction between these modules: `pathlib`
imported `pathlib._abc` but not `pathlib.types`. This is no longer the
case (neither module is imported), so we move the ABCs as follows:

- `pathlib._abc.JoinablePath` --> `pathlib.types._JoinablePath`
- `pathlib._abc.ReadablePath` --> `pathlib.types._ReadablePath`
- `pathlib._abc.WritablePath` --> `pathlib.types._WritablePath`

8 months agogh-130453: pygettext: Allow overriding default keywords when using `--keyword` (GH...
Tomas R. [Mon, 3 Mar 2025 16:57:01 +0000 (17:57 +0100)] 
gh-130453: pygettext: Allow overriding default keywords when using `--keyword` (GH-130709)

8 months agogh-130711: Document `PyBaseObject_Type` (GH-130712)
Yuki Kobayashi [Mon, 3 Mar 2025 14:08:05 +0000 (23:08 +0900)] 
gh-130711: Document `PyBaseObject_Type` (GH-130712)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
8 months agogh-100388: Change undefined __DATE__ to the Unix epoch (#100389)
Samuel Tyler [Mon, 3 Mar 2025 13:59:46 +0000 (00:59 +1100)] 
gh-100388: Change undefined __DATE__ to the Unix epoch (#100389)

8 months agogh-129173: refactor `PyCodec_BackslashReplaceErrors` into separate functions (#129895)
Bénédikt Tran [Mon, 3 Mar 2025 12:58:15 +0000 (13:58 +0100)] 
gh-129173: refactor `PyCodec_BackslashReplaceErrors` into separate functions (#129895)

The logic of `PyCodec_BackslashReplaceErrors` is now split into separate functions,
each of which handling a specific exception type.

8 months ago`unittest.mock` test and coverage fixup (#130787)
Chris Withers [Mon, 3 Mar 2025 11:44:59 +0000 (11:44 +0000)] 
`unittest.mock` test and coverage fixup (#130787)

* Mark functions that will never be called with # pragma: no cover

* Fix testpatch.PatchTest.test_exit_idempotent

.stop() and __exit__ have subtly different code paths, so to really test __exit__ idempotency, we need to call it specifically twice.

8 months agogh-129173: simplify `PyCodec_XMLCharRefReplaceErrors` logic (#129894)
Bénédikt Tran [Mon, 3 Mar 2025 11:43:22 +0000 (12:43 +0100)] 
gh-129173: simplify `PyCodec_XMLCharRefReplaceErrors` logic (#129894)

Writing the decimal representation of a Unicode codepoint only requires to know the number of digits.

---------

Co-authored-by: Petr Viktorin <encukou@gmail.com>
8 months agodocs: internal notes have moved, correct references (#130762)
Ned Batchelder [Mon, 3 Mar 2025 11:38:49 +0000 (04:38 -0700)] 
docs: internal notes have moved, correct references (#130762)

8 months agogh-130149: refactor tests for HMAC (#130150)
Bénédikt Tran [Mon, 3 Mar 2025 10:22:05 +0000 (11:22 +0100)] 
gh-130149: refactor tests for HMAC (#130150)

Since we plan to introduce a built-in implementation for HMAC based on HACL*,
it becomes important for the HMAC tests to be flexible enough to avoid code
duplication.

In addition to the new layout based on mixin classes, we extend test coverage by
also testing the `__repr__` of HMAC objects and the HMAC one-shot functions.

We also fix the import to `_sha256` which, since gh-101924, resulted in some tests being
skipped as the module is no more available (its content was moved to the `_sha2` module).

8 months agogh-101100: Fix sphinx warnings in `library/email.errors.rst` (#130774)
Yuki Kobayashi [Mon, 3 Mar 2025 09:56:45 +0000 (18:56 +0900)] 
gh-101100: Fix sphinx warnings in `library/email.errors.rst` (#130774)

8 months agogh-101100: Fix Sphinx documentation warnings in `collections.rst` (#130629)
Victorien [Mon, 3 Mar 2025 09:46:38 +0000 (10:46 +0100)] 
gh-101100: Fix Sphinx documentation warnings in `collections.rst` (#130629)

8 months agogh-129015: Improve disambiguation between `NotImplemented` and `NotImplementedError...
Mike Castle [Mon, 3 Mar 2025 08:23:41 +0000 (00:23 -0800)] 
gh-129015: Improve disambiguation between `NotImplemented` and `NotImplementedError` (#129562)

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
8 months agogh-127667: fix memory leaks in `hashlib` (#127668)
Bénédikt Tran [Mon, 3 Mar 2025 08:20:33 +0000 (09:20 +0100)] 
gh-127667: fix memory leaks in `hashlib` (#127668)

- Correctly handle `NULL` values returned by `EVP_MD_CTX_md`.
- Correctly free resources in error branches.
- Consistently suppress `_setException()` return value when needed.
- Collapse `_setException() + return NULL` into a single statement.

8 months agogh-128002: use efficient linked list implementation for eager tasks in asyncio (...
Kumar Aditya [Mon, 3 Mar 2025 06:36:43 +0000 (12:06 +0530)] 
gh-128002: use efficient linked list implementation for eager tasks in asyncio (#130518)

8 months agogh-128041: Add `terminate_workers` and `kill_workers` methods to ProcessPoolExecutor...
Charles Machalow [Mon, 3 Mar 2025 02:01:45 +0000 (18:01 -0800)] 
gh-128041: Add `terminate_workers` and `kill_workers` methods to ProcessPoolExecutor (GH-128043)

This adds two new methods to `multiprocessing`'s `ProcessPoolExecutor`:
- **`terminate_workers()`**: forcefully terminates worker processes using `Process.terminate()`
- **`kill_workers()`**: forcefully kills worker processes using `Process.kill()`

These methods provide users with a direct way to stop worker processes without `shutdown()` or relying on implementation details, addressing situations where immediate termination is needed.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Commit-message-mostly-authored-by: Claude Sonnet 3.7 (because why not -greg)
8 months agoGH-130415: Use boolean guards to narrow types to values in the JIT (GH-130659)
Brandt Bucher [Sun, 2 Mar 2025 21:21:34 +0000 (13:21 -0800)] 
GH-130415: Use boolean guards to narrow types to values in the JIT (GH-130659)

8 months agogh-128481: indicate that the default value for `FrameSummary.end_lineno` changed...
Bénédikt Tran [Sun, 2 Mar 2025 17:16:51 +0000 (18:16 +0100)] 
gh-128481: indicate that the default value for `FrameSummary.end_lineno` changed in 3.13 (#130755)

The value taken by `FrameSummary.end_lineno` when passing `end_lineno=None` changed in gh-112097.

Previously, a `end_lineno` could be specified to be `None` directly but since 939fc6d, passing None makes
the constructor use the value of `lineno` instead.

8 months agogh-130637: Add validation for numeric response data in `stat()` method (#130646)
Kanishk Pachauri [Sun, 2 Mar 2025 13:05:40 +0000 (18:35 +0530)] 
gh-130637: Add validation for numeric response data in `stat()` method (#130646)

Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
8 months agogh-89083: add support for UUID version 6 (RFC 9562) (#120650)
Bénédikt Tran [Sun, 2 Mar 2025 11:41:56 +0000 (12:41 +0100)] 
gh-89083: add support for UUID version 6 (RFC 9562) (#120650)

Add support for generating UUIDv6 objects according to RFC 9562, §5.6 [1].

The functionality is provided by the `uuid.uuid6()` function which takes as inputs an optional 48-bit
hardware address and an optional 14-bit clock sequence. The UUIDv6 temporal fields are ordered
differently than those of UUIDv1, thereby providing improved database locality.

[1]: https://www.rfc-editor.org/rfc/rfc9562.html#section-5.6

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
8 months agogh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)
Hugo Beauzée-Luyssen [Sun, 2 Mar 2025 09:56:49 +0000 (10:56 +0100)] 
gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)

Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h`.

8 months agogh-128481: Improve documentation for `traceback.FrameSummary` (#128484)
Damien [Sun, 2 Mar 2025 09:29:12 +0000 (17:29 +0800)] 
gh-128481: Improve documentation for `traceback.FrameSummary` (#128484)

Complete the `traceback.FrameSummary` signature and add missing
documentation for the `colno` and `end_{col,line}no` attributes.

8 months agoFix grammar typo in `Doc/c-api/arg.rst` (#130741)
Arijit Kumar Das [Sun, 2 Mar 2025 09:24:34 +0000 (14:54 +0530)] 
Fix grammar typo in `Doc/c-api/arg.rst` (#130741)

8 months agoAdd link in the `importlib.metadata.version()` docs (#130739)
Tim Hoffmann [Sun, 2 Mar 2025 09:23:32 +0000 (10:23 +0100)] 
Add link in the `importlib.metadata.version()` docs (#130739)

Link the specification for the returned data makes it clearer what this is
and what the format of the version string can be.

8 months agoGH-127381: pathlib ABCs: remove `WritablePath.mkdir()` arguments (#130611)
Barney Gale [Sat, 1 Mar 2025 21:25:38 +0000 (21:25 +0000)] 
GH-127381: pathlib ABCs: remove `WritablePath.mkdir()` arguments (#130611)

Remove the *mode*, *parents* and *exist_ok* arguments from
`WritablePath.mkdir()`. These arguments imply support for POSIX permissions
and checking for preexistence of the path or its parents, but subclasses of
`WritablePath` may not have these capabilities.

The public `Path.mkdir()` method retains these arguments.

8 months agoGH-127381: pathlib ABCs: remove `ReadablePath.exists()` and `is_*()` (#130520)
Barney Gale [Sat, 1 Mar 2025 21:24:19 +0000 (21:24 +0000)] 
GH-127381: pathlib ABCs: remove `ReadablePath.exists()` and `is_*()` (#130520)

Remove `ReadablePath` methods duplicated by `ReadablePath.info`. To be
specific, we remove `exists()`, `is_dir()`, `is_file()` and `is_symlink()`.

The public `Path` class retains these methods.

8 months agogh-130160: use `.. program::` directive for documenting `cProfile` CLI (#130314)
Apostol Fet [Sat, 1 Mar 2025 20:39:25 +0000 (23:39 +0300)] 
gh-130160: use `.. program::` directive for documenting `cProfile` CLI (#130314)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
8 months agogh-129401: Test repr rlock failing randomly (#129959)
Duprat [Sat, 1 Mar 2025 20:28:14 +0000 (21:28 +0100)] 
gh-129401: Test repr rlock failing randomly (#129959)

Fix and simplify a test of `test_repr_rlock` about multiprocessing.RLock primitive.

8 months agoRevert "GH-116380: Speed up `glob.[i]glob()` by making fewer system calls. (#116392...
Barney Gale [Sat, 1 Mar 2025 20:04:01 +0000 (20:04 +0000)] 
Revert "GH-116380: Speed up `glob.[i]glob()` by making fewer system calls. (#116392)" (#130743)

This broke tests on the 'aarch64 Fedora Stable Clang Installed 3.x' and
'AMD64 Fedora Stable Clang Installed 3.x' build bots.

This reverts commit da4899b94a9a9083fed4972b2473546e0d997727.

8 months agoRevert "gh-128364: Fix flaky `test_timeout` test (gh-130724)" (gh-130732)
Sam Gross [Sat, 1 Mar 2025 17:22:13 +0000 (12:22 -0500)] 
Revert "gh-128364: Fix flaky `test_timeout` test (gh-130724)" (gh-130732)

Change broke Android and iOS buildbots that do not have multiprocessing.

This reverts commit cfa0b1dc375e63cde28e61a47108c645b0e74834.

8 months agogh-128364: Fix flaky `test_timeout` test (gh-130724)
Sam Gross [Sat, 1 Mar 2025 16:20:43 +0000 (11:20 -0500)] 
gh-128364: Fix flaky `test_timeout` test (gh-130724)

8 months agogh-128974: Fix `UnicodeError.__str__` when custom attributes have side-effects (...
Bénédikt Tran [Sat, 1 Mar 2025 11:01:20 +0000 (12:01 +0100)] 
gh-128974: Fix `UnicodeError.__str__` when custom attributes have side-effects (#128975)

Fix some crashes when (custom) attributes of `UnicodeError` objects implement `object.__str__` with side-effects.

8 months agoRevert "gh-128942: make `array` module thread safe (#128943)" (#130707)
Sam Gross [Fri, 28 Feb 2025 21:57:48 +0000 (16:57 -0500)] 
Revert "gh-128942: make `array` module thread safe (#128943)" (#130707)

The change regressed performance on scimark benchmarks from the
pyperformance benchmark suite.

This reverts commit 8ba0d7bbc295781bf27902380521db97a272c442.

8 months agoGH-116380: Speed up `glob.[i]glob()` by making fewer system calls. (#116392)
Barney Gale [Fri, 28 Feb 2025 20:33:51 +0000 (20:33 +0000)] 
GH-116380: Speed up `glob.[i]glob()` by making fewer system calls. (#116392)

## Filtered recursive walk

Expanding a recursive `**` segment entails walking the entire directory
tree, and so any subsequent pattern segments (except special segments) can
be evaluated by filtering the expanded paths through a regex. For example,
`glob.glob("foo/**/*.py", recursive=True)` recursively walks `foo/` with
`os.scandir()`, and then filters paths through a regex based on "`**/*.py`,
with no further filesystem access needed.

This fixes an issue where `glob()` could return duplicate results.

## Tracking path existence

We store a flag alongside each path indicating whether the path is
guaranteed to exist. As we process the pattern:

- Certain special pattern segments (`""`, `"."` and `".."`) leave the flag
  unchanged
- Literal pattern segments (e.g. `foo/bar`) set the flag to false
- Wildcard pattern segments (e.g. `*/*.py`) set the flag to true (because
  children are found via `os.scandir()`)
- Recursive pattern segments (e.g. `**`) leave the flag unchanged for the
  root path, and set it to true for descendants discovered via
  `os.scandir()`.

If the flag is false at the end, we call `lstat()` on each path to filter
out missing paths.

## Minor speed-ups

- Exclude paths that don't match a non-terminal non-recursive wildcard
  pattern _prior_ to calling `is_dir()`.
- Use a stack rather than recursion to implement recursive wildcards.
  - This fixes a recursion error when globbing deep trees.
- Pre-compile regular expressions and pre-join literal pattern segments.
- Convert to/from `bytes` (a minor use-case) in `iglob()` rather than
  supporting `bytes` throughout. This particularly simplifies the code
  needed to handle relative bytes paths with `dir_fd`.
- Avoid calling `os.path.join()`; instead we keep paths in a normalized
  form and append trailing slashes when needed.
- Avoid calling `os.path.normcase()`; instead we use case-insensitive regex
  matching.

## Implementation notes

Much of this functionality is already present in pathlib's implementation
of globbing. The specific additions we make are:

1. Support for `dir_fd`
2. Support for `include_hidden`
3. Support for generating paths relative to `root_dir`

This unifies the implementations of globbing in the `glob` and `pathlib`
modules.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>