]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
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>
8 months agoGH-130608: Remove `dirs_exist_ok` argument from `pathlib.Path.copy()` (#130610)
Barney Gale [Fri, 28 Feb 2025 19:29:20 +0000 (19:29 +0000)] 
GH-130608: Remove `dirs_exist_ok` argument from `pathlib.Path.copy()` (#130610)

This feature isn't sufficiently motivated.

8 months agogh-130660: Restore sys.ps1 and sys.ps2 after code.interact (#130661)
Tian Gao [Fri, 28 Feb 2025 18:15:55 +0000 (13:15 -0500)] 
gh-130660: Restore sys.ps1 and sys.ps2 after code.interact (#130661)

8 months agoGH-130296: Avoid stack transients in four instructions. (GH-130310)
Mark Shannon [Fri, 28 Feb 2025 18:00:38 +0000 (18:00 +0000)] 
GH-130296: Avoid stack transients in four instructions. (GH-130310)

* Combine _GUARD_GLOBALS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_MODULE_FROM_KEYS into _LOAD_GLOBAL_MODULE

* Combine _GUARD_BUILTINS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_BUILTINS_FROM_KEYS into _LOAD_GLOBAL_BUILTINS

* Combine _CHECK_ATTR_MODULE_PUSH_KEYS and _LOAD_ATTR_MODULE_FROM_KEYS into _LOAD_ATTR_MODULE

* Remove stack transient in LOAD_ATTR_WITH_HINT

8 months agogh-129666: Revert "gh-129666: Add C11/C++11 to docs and `-pedantic-errors` to GCC...
Petr Viktorin [Fri, 28 Feb 2025 16:05:36 +0000 (17:05 +0100)] 
gh-129666: Revert "gh-129666: Add C11/C++11 to docs and `-pedantic-errors` to GCC/clang test_c[pp]ext tests (GH-130686)" (GH-130688)

This reverts commit 003e6d2b9776c07147a9c628eb028fd2ac3f0008.

8 months agogh-129666: Add C11/C++11 to docs and `-pedantic-errors` to GCC/clang test_c[pp]ext...
Petr Viktorin [Fri, 28 Feb 2025 15:03:02 +0000 (16:03 +0100)] 
gh-129666: Add C11/C++11 to docs and `-pedantic-errors` to GCC/clang test_c[pp]ext tests (GH-130686)

8 months agogh-124878: Add temporary TSAN suppression for free_threadstate (gh-130602)
Sam Gross [Fri, 28 Feb 2025 14:27:51 +0000 (09:27 -0500)] 
gh-124878: Add temporary TSAN suppression for free_threadstate (gh-130602)

The race condition with `free_threadstate` and daemon threads exists in
both the free threading and default builds. We were missing a
suppression in the default build.

8 months agogh-130605: Use relaxed atomics to set the GIL switch interval (gh-130654)
Sam Gross [Fri, 28 Feb 2025 14:27:18 +0000 (09:27 -0500)] 
gh-130605: Use relaxed atomics to set the GIL switch interval (gh-130654)

The interval may be concurrently read by a thread attempting to acquire
the GIL.

8 months agogh-130665: Only apply locale to calendar CLI via `--locale` and not `LANG` env var...
Hugo van Kemenade [Fri, 28 Feb 2025 14:24:05 +0000 (16:24 +0200)] 
gh-130665: Only apply locale to calendar CLI via `--locale` and not `LANG` env var (#130676)

8 months agogh-46236: PyUnicode docs improvements (GH-129966)
Petr Viktorin [Fri, 28 Feb 2025 14:11:44 +0000 (15:11 +0100)] 
gh-46236: PyUnicode docs improvements (GH-129966)

Move deprecated PyUnicode API docs to new section

Move Py_UNICODE to a new "Deprecated API" section.

Formally soft-deprecate PyUnicode_READY, and move it

Document and soft-deprecate PyUnicode_IS_READY, and move it

Document PyUnicode_IS_ASCII, PyUnicode_CHECK_INTERNED

PyUnicode_New docs: Clarify requirements for "fresh" strings

PyUnicodeWriter_DecodeUTF8Stateful: Link "error-handlers"

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
8 months agogh-130607: Extend and cleanup IPv6 tests (GH-121518)
Ilya Bazhenov [Fri, 28 Feb 2025 10:31:30 +0000 (13:31 +0300)] 
gh-130607: Extend and cleanup IPv6 tests (GH-121518)

Extend IPv6 tests and made little syntax refactoring

8 months agoPostpone <stdbool.h> inclusion after Python.h (#130641)
Hugo Beauzée-Luyssen [Fri, 28 Feb 2025 09:09:27 +0000 (10:09 +0100)] 
Postpone <stdbool.h> inclusion after Python.h (#130641)

Remove inclusions prior to Python.h.

<stdbool.h> will cause <features.h> to be included before Python.h can
define some macros to enable some additional features, causing multiple
types not to be defined down the line.

8 months agogh-130595: Fix leak in WITH_EXCEPT_START error case (GH-130626)
Petr Viktorin [Fri, 28 Feb 2025 08:58:50 +0000 (09:58 +0100)] 
gh-130595: Fix leak in WITH_EXCEPT_START error case (GH-130626)

Co-authored-by: Ken Jin <kenjin@python.org>
8 months agogh-130655: Increase test coverage of gettext._expand_lang() (GH-130656)
Tomas R. [Fri, 28 Feb 2025 08:40:36 +0000 (09:40 +0100)] 
gh-130655: Increase test coverage of gettext._expand_lang() (GH-130656)

8 months agogh-129726: Break `gzip.GzipFile` reference loop (#130055)
Cody Maloney [Fri, 28 Feb 2025 08:09:24 +0000 (00:09 -0800)] 
gh-129726: Break `gzip.GzipFile` reference loop (#130055)

A reference loop was resulting in the `fileobj` held by the `GzipFile`
being closed before the `GzipFile`.

The issue started with gh-89550 in 3.12, but was hidden in most cases
until 3.13 when gh-62948 made it more visible.

8 months agogh-130617 : fix time_clockid_converter on DragonFlyBSD (#130634)
leleliu008 [Fri, 28 Feb 2025 07:56:00 +0000 (15:56 +0800)] 
gh-130617 : fix time_clockid_converter on DragonFlyBSD (#130634)

Signed-off-by: leleliu008 <leleliu008@gmail.com>
8 months agogh-129200: Add locking to the iOS testbed startup sequence. (#130564)
Russell Keith-Magee [Thu, 27 Feb 2025 23:33:10 +0000 (07:33 +0800)] 
gh-129200: Add locking to the iOS testbed startup sequence. (#130564)

Add a lock to ensure that only one iOS testbed per user can start at a time, so
that the simulator discovery process doesn't collide between instances.

8 months agogh-127271: Remove the PyCell_Get usage for framelocalsproxy (#130383)
Tian Gao [Thu, 27 Feb 2025 23:12:04 +0000 (18:12 -0500)] 
gh-127271: Remove the PyCell_Get usage for framelocalsproxy (#130383)

8 months agoGH-121970: Extract ``issue_role`` into a new extension (#130615)
Adam Turner [Thu, 27 Feb 2025 19:06:13 +0000 (19:06 +0000)] 
GH-121970: Extract ``issue_role`` into a new extension (#130615)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
8 months agogh-130091: Reorder `_PyThreadState_Attach` to avoid data race (gh-130092)
Sam Gross [Thu, 27 Feb 2025 18:57:19 +0000 (13:57 -0500)] 
gh-130091: Reorder `_PyThreadState_Attach` to avoid data race (gh-130092)

This moves `tstate_activate()` down to avoid a data race in the free
threading build on the `_PyRuntime`'s thread-local `autoTSSkey`. This
key is deleted during runtime finalization, which may happen
concurrently with a call to `_PyThreadState_Attach`.

The earlier `tstate_try/wait_attach` ensures that the thread is blocked
before it attempts to access the deleted `autoTSSkey`.

This fixes a TSAN reported data race in
`test_threading.test_import_from_another_thread`.

8 months agogh-130618: Fix parser error when using lambdas inside f-strings (#130638)
Pablo Galindo Salgado [Thu, 27 Feb 2025 15:51:17 +0000 (15:51 +0000)] 
gh-130618: Fix parser error when using lambdas inside f-strings (#130638)

8 months agoDocs: Fix a misplaced statement in the document for `ServerProxy` (GH-130616)
Yuki Kobayashi [Thu, 27 Feb 2025 15:14:56 +0000 (00:14 +0900)] 
Docs: Fix a misplaced statement in the document for `ServerProxy` (GH-130616)

The sentence "If an HTTPS URL ..." explains what the parameter means,
so moved it to the paragraph explaining what the other parameters mean.

8 months agogh-129107: fix thread safety of `bytearray` where two critical sections are needed...
Tomasz Pytel [Thu, 27 Feb 2025 14:59:58 +0000 (09:59 -0500)] 
gh-129107: fix thread safety of `bytearray` where two critical sections are needed (#130227)

8 months agogh-128942: make `array` module thread safe (#128943)
Tomasz Pytel [Thu, 27 Feb 2025 14:00:14 +0000 (09:00 -0500)] 
gh-128942: make `array` module thread safe (#128943)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
8 months agogh-130421: Fix data race on timebase initialization (gh-130592)
Sam Gross [Thu, 27 Feb 2025 13:27:54 +0000 (08:27 -0500)] 
gh-130421: Fix data race on timebase initialization (gh-130592)

Windows and macOS require precomputing a "timebase" in order to convert
OS timestamps into nanoseconds. Retrieve and compute this value during
runtime initialization to avoid data races when accessing the time.

8 months agogh-129288: Add optional l2_cid and l2_bdaddr_type in BTPROTO_L2CAP socket address...
Fredrik Ahlberg [Thu, 27 Feb 2025 12:51:47 +0000 (13:51 +0100)] 
gh-129288: Add optional l2_cid and l2_bdaddr_type in BTPROTO_L2CAP socket address tuple (#129293)

Add two optional, traling elements in the AF_BLUETOOTH socket address tuple:

- l2_cid, to allow e.g raw LE ATT connections
- l2_bdaddr_type. To be able to connect L2CAP sockets to Bluetooth LE devices,
  the l2_bdaddr_type must be set to BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM.

8 months agogh-109959: Remove test_glob.test_selflink() (#130551)
Victor Stinner [Thu, 27 Feb 2025 10:07:08 +0000 (11:07 +0100)] 
gh-109959: Remove test_glob.test_selflink() (#130551)

The test is not reliable, it fails randomly on Linux:
https://github.com/python/cpython/issues/109959#issuecomment-2577550700

8 months agoGH-128534: Instrument branches for `async for` loops. (GH-130569)
Mark Shannon [Thu, 27 Feb 2025 09:36:41 +0000 (09:36 +0000)] 
GH-128534: Instrument branches for `async for` loops. (GH-130569)

8 months agogh-130604: Always run all matrix workflows in GitHub Actions (#130603)
Adam Turner [Wed, 26 Feb 2025 21:44:48 +0000 (21:44 +0000)] 
gh-130604: Always run all matrix workflows in GitHub Actions (#130603)

8 months agogh-130605: Temporarily disable test_concurrent_futures in TSAN CI job (gh-130606)
Sam Gross [Wed, 26 Feb 2025 21:36:53 +0000 (16:36 -0500)] 
gh-130605: Temporarily disable test_concurrent_futures in TSAN CI job (gh-130606)

There are a number of data races in the default build without
suppressions that are exposed by this test. Disable the test for now
under TSAN until we have suppressions or fix the data races.

8 months agoGH-125413: Add private `pathlib.Path` method to write metadata (#130238)
Barney Gale [Wed, 26 Feb 2025 21:07:27 +0000 (21:07 +0000)] 
GH-125413: Add private `pathlib.Path` method to write metadata (#130238)

Replace `WritablePath._copy_writer` with a new `_write_info()` method. This
method allows the target of a `copy()` to preserve metadata.

Replace `pathlib._os.CopyWriter` and `LocalCopyWriter` classes with new
`copy_file()` and `copy_info()` functions. The `copy_file()` function uses
`source_path.info` wherever possible to save on `stat()`s.

8 months agogh-127785: Reduce permissions in the `check labels` workflow (#130596)
shenxianpeng [Wed, 26 Feb 2025 20:47:41 +0000 (04:47 +0800)] 
gh-127785: Reduce permissions in the `check labels` workflow (#130596)

8 months agogh-111178: Fix function signatures in sliceobject.c (#130575)
Victor Stinner [Wed, 26 Feb 2025 20:37:22 +0000 (21:37 +0100)] 
gh-111178: Fix function signatures in sliceobject.c (#130575)

Rename slicehash() to slice_hash() for consistency.

8 months agogh-111178: Fix function signatures in instruction_sequence.c (#130591)
Victor Stinner [Wed, 26 Feb 2025 20:36:26 +0000 (21:36 +0100)] 
gh-111178: Fix function signatures in instruction_sequence.c (#130591)

8 months agogh-111178: Fix function signatures in namespaceobject.c (#130590)
Victor Stinner [Wed, 26 Feb 2025 20:35:56 +0000 (21:35 +0100)] 
gh-111178: Fix function signatures in namespaceobject.c (#130590)

8 months agogh-111178: Fix function signatures in symtable.c (#130589)
Victor Stinner [Wed, 26 Feb 2025 20:35:24 +0000 (21:35 +0100)] 
gh-111178: Fix function signatures in symtable.c (#130589)

8 months agoDoc: Strip trailing whitespace in ``pydoc_topics`` (#130492)
Adam Turner [Wed, 26 Feb 2025 20:10:55 +0000 (20:10 +0000)] 
Doc: Strip trailing whitespace in ``pydoc_topics`` (#130492)

8 months agogh-130519: Fix crash in QSBR when destructor reenters QSBR (gh-130553)
Sam Gross [Wed, 26 Feb 2025 19:55:15 +0000 (14:55 -0500)] 
gh-130519: Fix crash in QSBR when destructor reenters QSBR (gh-130553)

The `free_work_item()` function in QSBR may call arbitrary code via
Python object destructors, which may reenter the QSBR code. Reorder
the processing of work items to be robust to reentrancy.

Also fix the TODO for the out of memory situation.

8 months agogh-130595: Keep traceback alive for WITH_EXCEPT_START (#130562)
Dino Viehland [Wed, 26 Feb 2025 18:41:26 +0000 (10:41 -0800)] 
gh-130595: Keep traceback alive for WITH_EXCEPT_START (#130562)

Keep traceback alive for WITH_EXCEPT_START

8 months agogh-128982: Revert "#128982: Substitute regular expression in http.cookiejar.join_head...
Petr Viktorin [Wed, 26 Feb 2025 14:42:39 +0000 (15:42 +0100)] 
gh-128982: Revert "#128982: Substitute regular expression in http.cookiejar.join_header_words for an efficient alternative (GH-128983)" and add tests (GH-130584)

* Revert "gh-128982: Substitute regular expression in `http.cookiejar.join_header_words` for an efficient alternative (GH-128983)"

This reverts commit 56e190068177855266f32a7efa329d145b279f94.

* Add tests

8 months agogh-128982: Substitute regular expression in `http.cookiejar.join_header_words` for...
Bénédikt Tran [Wed, 26 Feb 2025 12:01:32 +0000 (13:01 +0100)] 
gh-128982: Substitute regular expression in `http.cookiejar.join_header_words` for an efficient alternative (GH-128983)

The function does not anymore rely on a regular expression
to find alphanumeric characters and underscores.

8 months agogh-130379: Fix incorrect zipapp logic to avoid including the target in itself (gh...
Paul Moore [Wed, 26 Feb 2025 11:25:30 +0000 (11:25 +0000)] 
gh-130379: Fix incorrect zipapp logic to avoid including the target in itself (gh-130509)

8 months agogh-111178: fix UBSan failures in `Modules/_hashopenssl.c` (GH-129802)
Bénédikt Tran [Wed, 26 Feb 2025 09:24:44 +0000 (10:24 +0100)] 
gh-111178: fix UBSan failures in `Modules/_hashopenssl.c` (GH-129802)

Fix UBSan failures for `EVPobject`, `HMACobject`

8 months agoGH-130396: Treat clang -Og as optimized for gdb tests (GH-130550)
Mark Shannon [Wed, 26 Feb 2025 09:01:58 +0000 (09:01 +0000)] 
GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550)

8 months agoGH-130396: Increase trashcan overhead (GH-130552)
Mark Shannon [Wed, 26 Feb 2025 08:54:24 +0000 (08:54 +0000)] 
GH-130396: Increase trashcan overhead (GH-130552)

Double trashcan overhead

8 months agogh-111178: fix UBSan failures in `Modules/_tkinter.c` (GH-129795)
Bénédikt Tran [Wed, 26 Feb 2025 08:40:48 +0000 (09:40 +0100)] 
gh-111178: fix UBSan failures in `Modules/_tkinter.c` (GH-129795)

Fix UBSan failures for `TkappObject`, `PyTclObject`, `TkttObject`

Implement CHECK_TCL_APPARTMENT as a static inline function

8 months agogh-111178: fix UBSan failures in `Modules/_zoneinfo.c` (GH-129798)
Bénédikt Tran [Wed, 26 Feb 2025 08:36:59 +0000 (09:36 +0100)] 
gh-111178: fix UBSan failures in `Modules/_zoneinfo.c` (GH-129798)

Fix UBSan failures for `PyZoneInfo_ZoneInfo`

Fix semantic naming

8 months agogh-130433: Update documentation for `MultipartConversionError` (GH-130436)
Yuki Kobayashi [Wed, 26 Feb 2025 08:34:10 +0000 (17:34 +0900)] 
gh-130433: Update documentation for `MultipartConversionError` (GH-130436)

8 months agogh-117657: Use an atomic store to set type flags. (gh-127588)
Neil Schemenauer [Wed, 26 Feb 2025 05:24:20 +0000 (21:24 -0800)] 
gh-117657: Use an atomic store to set type flags. (gh-127588)

The `PyType_HasFeature()` function reads the flags with a relaxed atomic
load and without holding the type lock.  To avoid data races, use atomic
stores if `PyType_Ready()` has already been called.

8 months agogh-130163: Fix crashes related to PySys_GetObject() (GH-130503)
Serhiy Storchaka [Tue, 25 Feb 2025 21:04:27 +0000 (23:04 +0200)] 
gh-130163: Fix crashes related to PySys_GetObject() (GH-130503)

The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().

8 months agoGH-130396: Include stack margin for debug windows builds (GH-130554)
Mark Shannon [Tue, 25 Feb 2025 19:26:21 +0000 (19:26 +0000)] 
GH-130396: Include stack margin for debug windows builds (GH-130554)

8 months agogh-130202: Fix bug in `_PyObject_ResurrectEnd` in free threaded build (gh-130281)
Sam Gross [Tue, 25 Feb 2025 17:03:28 +0000 (12:03 -0500)] 
gh-130202: Fix bug in `_PyObject_ResurrectEnd` in free threaded build (gh-130281)

This fixes a fairly subtle bug involving finalizers and resurrection in
debug free threaded builds: if `_PyObject_ResurrectEnd` returns `1`
(i.e., the object was resurrected by a finalizer), it's not safe to
access the object because it might still be deallocated. For example:

 * The finalizer may have exposed the object to another thread. That
   thread may hold the last reference and concurrently deallocate it any
   time after `_PyObject_ResurrectEnd()` returns `1`.
 * `_PyObject_ResurrectEnd()` may call `_Py_brc_queue_object()`, which
   may internally deallocate the object immediately if the owning thread
   is dead.

Therefore, it's important not to access the object after it's
resurrected. We only violate this in two cases, and only in debug
builds:

 * We assert that the object is tracked appropriately. This is now moved
   up betewen the finalizer and the `_PyObject_ResurrectEnd()` call.

 * The `--with-trace-refs` builds may need to remember the object if
   it's resurrected. This is now handled by `_PyObject_ResurrectStart()`
   and `_PyObject_ResurrectEnd()`.

Note that `--with-trace-refs` is currently disabled in `--disable-gil`
builds because the refchain hash table isn't thread-safe, but this
refactoring avoids an additional thread-safety issue.

8 months agogh-122029: Move monitoring after method expand for CALL_KW (GH-130488)
Tian Gao [Tue, 25 Feb 2025 15:43:49 +0000 (10:43 -0500)] 
gh-122029: Move monitoring after method expand for CALL_KW (GH-130488)

8 months agogh-129824: Temporarily skip InterpreterPoolMixin tests under TSAN (gh-129826)
Sam Gross [Tue, 25 Feb 2025 15:33:04 +0000 (10:33 -0500)] 
gh-129824: Temporarily skip InterpreterPoolMixin tests under TSAN (gh-129826)

There are multiple data races reported when running the
InterpreterPoolMixin tests, but it's still useful to run the other
test_concurrent_futures tests under TSAN.

Add test_concurrent_futures to the TSAN test suite.

8 months agogh-87790: support thousands separators for formatting fractional part of floats ...
Sergey B Kirpichev [Tue, 25 Feb 2025 15:27:07 +0000 (18:27 +0300)] 
gh-87790: support thousands separators for formatting fractional part of floats (#125304)

```pycon
>>> f"{123_456.123_456:_._f}"  # Whole and fractional
'123_456.123_456'
>>> f"{123_456.123_456:_f}"    # Integer component only
'123_456.123456'
>>> f"{123_456.123_456:._f}"   # Fractional component only
'123456.123_456'
>>> f"{123_456.123_456:.4_f}"  # with precision
'123456.1_235'
```

8 months agogh-129173: refactor `PyCodec_ReplaceErrors` into separate functions (#129893)
Bénédikt Tran [Tue, 25 Feb 2025 13:24:46 +0000 (14:24 +0100)] 
gh-129173: refactor `PyCodec_ReplaceErrors` into separate functions (#129893)

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

8 months agoDocs: Fix some semantic usages of `iterator.__iter__` (GH-130172)
Yuki Kobayashi [Tue, 25 Feb 2025 12:38:47 +0000 (21:38 +0900)] 
Docs: Fix some semantic usages of `iterator.__iter__` (GH-130172)

These references to an `__iter__` method mean `object.__iter__`, not `iterator.__iter__`.

8 months agogh-130461: Remove unnecessary usages of `.. index::` directives in Doc/library/uuid...
Kanishk Pachauri [Tue, 25 Feb 2025 12:27:50 +0000 (17:57 +0530)] 
gh-130461: Remove unnecessary usages of `.. index::` directives in Doc/library/uuid.rst (#130526)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
8 months agogh-111178: fix UBSan failures in `Modules/unicodedata.c` (GH-129801)
Bénédikt Tran [Tue, 25 Feb 2025 12:13:47 +0000 (13:13 +0100)] 
gh-111178: fix UBSan failures in `Modules/unicodedata.c` (GH-129801)

fix UBSan failures for `PreviousDBVersion`

8 months agogh-111178: fix UBSan failures in `Objects/typevarobject.c` (GH-129800)
Bénédikt Tran [Tue, 25 Feb 2025 12:12:47 +0000 (13:12 +0100)] 
gh-111178: fix UBSan failures in `Objects/typevarobject.c` (GH-129800)

Fix UBSan failures for `typealiasobject`, `paramspecobject`, `typevarobject`, `typevartupleobject`, `paramspecattrobject`

Use _PyCFunction_CAST macros

Use macro for `constevaluatorobject` casts

8 months agogh-111178: fix UBSan failures in `Modules/xx*.c` (GH-129797)
Bénédikt Tran [Tue, 25 Feb 2025 12:02:32 +0000 (13:02 +0100)] 
gh-111178: fix UBSan failures in `Modules/xx*.c` (GH-129797)

Fix UBSan failures in `Modules/xxlimited.c`, `Modules/xxlimited_35.c`, `Modules/xxsubtype.c`, `Modules/xxmodule.c`

8 months agogh-111178: fix UBSan failures in `Objects/typeobject.c` (#129799)
Bénédikt Tran [Tue, 25 Feb 2025 10:44:59 +0000 (11:44 +0100)] 
gh-111178: fix UBSan failures in `Objects/typeobject.c` (#129799)

Fix UBSan failures for `PyTypeObject`.
Introduce a macro cast for `superobject` and remove redundant casts.
Rename the unused parameter in getter/setter methods  to `closure`
for semantic purposes.

8 months agogh-130453: pygettext: Extend support for specifying custom keywords (GH-130463)
Tomas R. [Tue, 25 Feb 2025 10:10:54 +0000 (11:10 +0100)] 
gh-130453: pygettext: Extend support for specifying custom keywords (GH-130463)

8 months agoFix a typo in `Py_DECREF` comment (#128387)
Justine Krejcha [Tue, 25 Feb 2025 10:10:40 +0000 (02:10 -0800)] 
Fix a typo in `Py_DECREF` comment (#128387)

8 months agoGH-130396: Use computed stack limits on linux (GH-130398)
Mark Shannon [Tue, 25 Feb 2025 09:24:48 +0000 (09:24 +0000)] 
GH-130396: Use computed stack limits on linux (GH-130398)

* Implement C recursion protection with limit pointers for Linux, MacOS and Windows

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow

8 months agogh-130292: Allow for empty simulator list when running iOS testbed (#130388)
Russell Keith-Magee [Tue, 25 Feb 2025 06:49:05 +0000 (14:49 +0800)] 
gh-130292: Allow for empty simulator list when running iOS testbed (#130388)

Adds error handling when there are no pre-existing test simulators.

8 months agoFix a typo in code module test (#130530)
Tian Gao [Tue, 25 Feb 2025 05:33:52 +0000 (00:33 -0500)] 
Fix a typo in code module test (#130530)