]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
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)

8 months agogh-124703: Change back to raising bdb.BdbQuit when exiting pdb in 'inline' mode in...
Adam D. Thomas [Tue, 25 Feb 2025 02:27:26 +0000 (13:27 +1100)] 
gh-124703: Change back to raising bdb.BdbQuit when exiting pdb in 'inline' mode in a REPL session (#130395)

8 months agogh-130419: Do not build the _freeze_module project twice in Windows PGO builds (GH...
Chris Eibl [Mon, 24 Feb 2025 21:35:00 +0000 (22:35 +0100)] 
gh-130419: Do not build the _freeze_module project twice in Windows PGO builds (GH-130420)

8 months agoGH-125413: Fix stale metadata from `pathlib.Path.copy()` and `move()` (#130424)
Barney Gale [Mon, 24 Feb 2025 19:10:50 +0000 (19:10 +0000)] 
GH-125413: Fix stale metadata from `pathlib.Path.copy()` and `move()` (#130424)

In `pathlib.Path.copy()` and `move()`, return a fresh `Path` object with an
unpopulated `info` attribute, rather than a `Path` object with information
recorded *prior* to the path's creation.

8 months agoGH-125413: pathlib ABCs: use caching `path.info.exists()` when globbing (#130422)
Barney Gale [Mon, 24 Feb 2025 19:07:54 +0000 (19:07 +0000)] 
GH-125413: pathlib ABCs: use caching `path.info.exists()` when globbing (#130422)

Call `ReadablePath.info.exists()` rather than `ReadablePath.exists()` when
globbing so that we use (or populate) the `info` cache.

8 months agogh-129874: improve tests to use correct implementations in asyncio (#130516)
Kumar Aditya [Mon, 24 Feb 2025 16:03:52 +0000 (21:33 +0530)] 
gh-129874: improve tests to use correct implementations in asyncio  (#130516)

8 months agogh-129874: avoid mixing pure python and C impl in eager execution (#130515)
Kumar Aditya [Mon, 24 Feb 2025 15:37:59 +0000 (21:07 +0530)] 
gh-129874: avoid mixing pure python and C impl in eager execution (#130515)

8 months agogh-130384: Skip a test_getallocatedblocks test pre-condition on iOS. (GH-130385)
Russell Keith-Magee [Mon, 24 Feb 2025 15:34:38 +0000 (23:34 +0800)] 
gh-130384: Skip a test_getallocatedblocks test pre-condition on iOS. (GH-130385)

8 months agogh-128231: Use `runcode()` return value for failing early (GH-129488)
Bartosz Sławecki [Mon, 24 Feb 2025 14:50:13 +0000 (15:50 +0100)] 
gh-128231: Use `runcode()` return value for failing early (GH-129488)

8 months agogh-46236: Add docs for PyUnicode_GetDefaultEncoding() doc (GH-130335)
RUANG (James Roy) [Mon, 24 Feb 2025 14:37:21 +0000 (22:37 +0800)] 
gh-46236: Add docs for PyUnicode_GetDefaultEncoding() doc (GH-130335)

* Clarify sys.getdefaultencoding() documentation

* Add missing documentation for PyUnicode_GetDefaultEncoding,
  the C equivalent of sys.getdefaultencoding

8 months agogh-129405: Fix doc for Py_mod_multiple_interpreters default, and add test (GH-129406)
Petr Viktorin [Mon, 24 Feb 2025 13:59:19 +0000 (14:59 +0100)] 
gh-129405: Fix doc for Py_mod_multiple_interpreters default, and add test (GH-129406)

8 months agogh-111178: fix UBSan failures in `Modules/_winapi.c` (GH-129796)
Bénédikt Tran [Mon, 24 Feb 2025 13:06:13 +0000 (14:06 +0100)] 
gh-111178: fix UBSan failures in `Modules/_winapi.c` (GH-129796)

Fix UBSan failures for `OverlappedObject`

Suppress unused return values

8 months agogh-127522: wsgiref: indicate that `start_response` objects should follow a specific...
Bénédikt Tran [Mon, 24 Feb 2025 12:43:56 +0000 (13:43 +0100)] 
gh-127522: wsgiref: indicate that `start_response` objects should follow a specific protocol (GH-127525)

8 months agogh-111178: fix UBSan failures in `Modules/_threadmodule.c` (GH-129794)
Bénédikt Tran [Mon, 24 Feb 2025 12:42:39 +0000 (13:42 +0100)] 
gh-111178: fix UBSan failures in `Modules/_threadmodule.c` (GH-129794)

Fix UBSan failures for `PyThreadHandleObject`, `lockobject`, `rlockobject`, `localdummyobject`, `localobject`

Add safe casts

Clean up module functions

Use semantically correct parameter names

8 months agogh-111178: fix UBSan failures in `Modules/selectmodule.c` (GH-129792)
Bénédikt Tran [Mon, 24 Feb 2025 12:38:18 +0000 (13:38 +0100)] 
gh-111178: fix UBSan failures in `Modules/selectmodule.c` (GH-129792)

Fix some UBSan failures for `pollObject`, `devpollObject`, `pyEpoll_Object` as well as
for `kqueue_event_Object`, `kqueue_queue_Object` and `kqueue_tracking_after_fork`.

Suppress unused return values.

Rename the unused parameter in `METH_NOARGS` and getter/setter methods to
`dummy` and `closure` respectively for semantic purposes.

Explicitly declare `_select_exec` as a `static` function.

8 months agogh-111178: fix UBSan failures in `Modules/posixmodule.c` (GH-129788)
Bénédikt Tran [Mon, 24 Feb 2025 12:20:49 +0000 (13:20 +0100)] 
gh-111178: fix UBSan failures in `Modules/posixmodule.c` (GH-129788)

Fix UBSan failures for `DirEntry`, `ScandirIterator`
Use better semantic naming

8 months agogh-111178: fix UBSan failures in `Modules/pyexpat.c` (GH-129789)
Bénédikt Tran [Mon, 24 Feb 2025 10:56:32 +0000 (11:56 +0100)] 
gh-111178: fix UBSan failures in `Modules/pyexpat.c` (GH-129789)

Fix UBSan failures for `xmlparseobject`, XML handler setters
Suppress unused return values

Rewrite `RC_HANDLER` with better semantics

8 months agoGH-91079: Revert "GH-91079: Implement C stack limits using addresses, not counters...
Petr Viktorin [Mon, 24 Feb 2025 10:16:08 +0000 (11:16 +0100)] 
GH-91079: Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now (GH130413)

Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now

Unfortunatlely, the change broke some buildbots.

This reverts commit 2498c22fa0a2b560491bc503fa676585c1a603d0.

8 months agogh-130160: use `.. program::` directive for documenting `idle` CLI (#130278)
Kanishk Pachauri [Mon, 24 Feb 2025 02:02:34 +0000 (07:32 +0530)] 
gh-130160: use `.. program::` directive for documenting `idle` CLI (#130278)

---------
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
8 months agogh-128641: Fix ConfigParser.read Perfomance Regression (#129596)
Andrew Shteren [Mon, 24 Feb 2025 00:20:37 +0000 (03:20 +0300)] 
gh-128641: Fix ConfigParser.read Perfomance Regression (#129596)

---------

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
8 months agogh-130151: Fix reference leaks in `_hashlib.hmac_{new,digest}` (GH-130152)
Bénédikt Tran [Mon, 24 Feb 2025 00:09:14 +0000 (01:09 +0100)] 
gh-130151: Fix reference leaks in `_hashlib.hmac_{new,digest}` (GH-130152)

* fix leak in `_hashlib.hmac_new`
* fix leak in `hmac_digest`
* fix exception type in `_hashlib.HMAC.copy`

8 months agogh-128627: Skip wasm-gc on iOS Safari where it's broken (#130418)
Łukasz Langa [Sun, 23 Feb 2025 23:26:04 +0000 (00:26 +0100)] 
gh-128627: Skip wasm-gc on iOS Safari where it's broken (#130418)

As of iOS 18.3.1, enabling wasm-gc breaks the interpreter. This disables the wasm-gc
trampoline on iOS.

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
8 months agogh-107773: Make `datetime` subclass `repr` consistent both implementations (#130308)
donBarbos [Sun, 23 Feb 2025 21:29:31 +0000 (01:29 +0400)] 
gh-107773: Make `datetime` subclass `repr` consistent both implementations (#130308)

---------

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
8 months agogh-129948: Add `set()` to `multiprocessing.managers.SyncManager` (#129949)
mingyu [Sun, 23 Feb 2025 20:07:33 +0000 (05:07 +0900)] 
gh-129948: Add `set()` to `multiprocessing.managers.SyncManager` (#129949)

The SyncManager provided support for various data structures such as dict, list, and queue, but oddly, not set.
This introduces support for set by defining SetProxy and registering it with SyncManager.

---
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
8 months agogh-124096: Enable REPL virtual terminal support on Windows (#124119)
Y5 [Sun, 23 Feb 2025 19:30:33 +0000 (03:30 +0800)] 
gh-124096: Enable REPL virtual terminal support on Windows (#124119)

To support virtual terminal mode in Windows PYREPL, we need a scanner
to read over the supported escaped VT sequences.

Windows REPL input was using virtual key mode, which does not support
terminal escape sequences. This patch calls `SetConsoleMode` properly
when initializing and send sequences to enable bracketed-paste modes
to support verbatim copy-and-paste.

Signed-off-by: y5c4l3 <y5c4l3@proton.me>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
Co-authored-by: wheeheee <104880306+wheeheee@users.noreply.github.com>
8 months agogh-65697: Prevent configparser from writing keys it cannot properly read (#129270)
Jacob Austin Lincoln [Sun, 23 Feb 2025 16:06:33 +0000 (08:06 -0800)] 
gh-65697: Prevent configparser from writing keys it cannot properly read (#129270)

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
8 months agogh-111178: fix UBSan failures in `Modules/_struct.c` (#129793)
Bénédikt Tran [Sun, 23 Feb 2025 10:34:11 +0000 (11:34 +0100)] 
gh-111178: fix UBSan failures in `Modules/_struct.c` (#129793)

Fix some UBSan failures for `PyStructObject` and `unpackiterobject`.

We also perform some cleanup by suppressing unused return values and renaming the
unused parameter in `METH_NOARGS` and getter methods to `dummy` and `closure`
respectively for semantic purposes.

8 months agogh-84559: improve What's New entry for `multiprocessing` start method changes (#128173)
Bénédikt Tran [Sun, 23 Feb 2025 09:35:08 +0000 (10:35 +0100)] 
gh-84559: improve What's New entry for `multiprocessing` start method changes (#128173)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
8 months agogh-121970: Replace `.. coroutine{method,function}` with `:async:` (#130448)
sobolevn [Sat, 22 Feb 2025 17:54:43 +0000 (20:54 +0300)] 
gh-121970: Replace `.. coroutine{method,function}` with `:async:` (#130448)

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
8 months agoDocs: Test presence of optional extensions with importlib (#130445)
Adam Turner [Sat, 22 Feb 2025 17:52:47 +0000 (17:52 +0000)] 
Docs: Test presence of optional extensions with importlib (#130445)

8 months agoAdd test checking value of a TypedDict's __total__ attribute when there is an assignm...
Daraan [Sat, 22 Feb 2025 17:34:22 +0000 (18:34 +0100)] 
Add test checking value of a TypedDict's __total__ attribute when there is an assignment in the class body. (#130460)

In relation to #109544 which changed this behavior.

Signed-off-by: Daniel Sperber <github.blurry@9ox.net>
8 months agoAdd measuring unit to `sys.getswitchinterval` docs (#130457)
sobolevn [Sat, 22 Feb 2025 16:05:10 +0000 (19:05 +0300)] 
Add measuring unit to `sys.getswitchinterval` docs (#130457)

8 months agogh-111178: fix clang-cl compilation of `Modules/mmapmodule.c` post gh-129784 (#130446)
Chris Eibl [Sat, 22 Feb 2025 11:36:38 +0000 (12:36 +0100)] 
gh-111178: fix clang-cl compilation of `Modules/mmapmodule.c` post gh-129784 (#130446)

The `PyCFunction` cast on `mmap__sizeof__method` was removed but the method was not updated accordingly.

8 months agogh-129712: Document the wheels tags corresponding to each universal SDK. (#130389)
Russell Keith-Magee [Sat, 22 Feb 2025 08:30:30 +0000 (16:30 +0800)] 
gh-129712: Document the wheels tags corresponding to each universal SDK. (#130389)

Document the architectures supported by macOS universal SDK configuration flags,
and add details on wheel tag naming.

8 months agoGH-121970: Replace custom abstract method directive with the ``:abstract:`` option...
Adam Turner [Sat, 22 Feb 2025 01:53:57 +0000 (01:53 +0000)] 
GH-121970: Replace custom abstract method directive with the ``:abstract:`` option (#129311)

8 months agogh-130159: Fix list indentation in collections.abc (#130165)
Adam Turner [Sat, 22 Feb 2025 01:41:15 +0000 (01:41 +0000)] 
gh-130159: Fix list indentation in collections.abc (#130165)

8 months agogh-126835: Move constant unaryop & binop folding to CFG (#129550)
Yan Yanchii [Fri, 21 Feb 2025 17:54:22 +0000 (18:54 +0100)] 
gh-126835: Move constant unaryop & binop folding to CFG (#129550)

8 months agoGH-128520: More consistent type-checking behaviour in pathlib (#130199)
Barney Gale [Fri, 21 Feb 2025 17:47:45 +0000 (17:47 +0000)] 
GH-128520: More consistent type-checking behaviour in pathlib (#130199)

In the following methods, skip casting of the argument to a path object if
the argument has a `with_segments` attribute. In `PurePath`:
`relative_to()`, `is_relative_to()`, `match()`, and `full_match()`. In
`Path`: `rename()`, `replace()`, `copy()`, `copy_into()`, `move()`, and
`move_into()`.

Previously the check varied a bit from method to method. The `PurePath`
methods used `isinstance(arg, PurePath)`; the `rename()` and `replace()`
methods always cast, and the remaining `Path` methods checked for a private
`_copy_writer` attribute.

We apply identical changes to relevant methods of the private ABCs. This
improves performance a bit, because `isinstance()` checks on ABCs are
expensive.

8 months agogh-130285: Fix handling of zero or empty counts in random.sample() (gh-130291)
Raymond Hettinger [Fri, 21 Feb 2025 17:33:10 +0000 (11:33 -0600)] 
gh-130285: Fix handling of zero or empty counts in random.sample() (gh-130291)

8 months agogh-126332: Add tests for _pyrepl.utils (#129325)
Pieter Eendebak [Fri, 21 Feb 2025 16:10:13 +0000 (17:10 +0100)] 
gh-126332: Add tests for _pyrepl.utils (#129325)

8 months agogh-129965: Add missing MIME types (#129969)
Hugo van Kemenade [Fri, 21 Feb 2025 15:44:53 +0000 (17:44 +0200)] 
gh-129965: Add missing MIME types (#129969)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
8 months agoGH-103180: Set a timeout for every job in GitHub Actions (#130375)
Adam Turner [Fri, 21 Feb 2025 15:11:26 +0000 (15:11 +0000)] 
GH-103180: Set a timeout for every job in GitHub Actions (#130375)

8 months agogh-111178: fix UBSan failures in `Modules/_randommodule.c` (GH-129791)
Bénédikt Tran [Fri, 21 Feb 2025 14:59:04 +0000 (15:59 +0100)] 
gh-111178: fix UBSan failures in `Modules/_randommodule.c` (GH-129791)

Fix UBSan failures for `RandomObject`
Suppress unused return values

8 months agogh-111178: fix UBSan failures in `Modules/_queuemodule.c` (GH-129790)
Bénédikt Tran [Fri, 21 Feb 2025 14:37:32 +0000 (15:37 +0100)] 
gh-111178: fix UBSan failures in `Modules/_queuemodule.c` (GH-129790)

Fix UBSan failures for `simplequeueobject`

Suppress unused return values

8 months agogh-111178: fix UBSan failures in `Modules/_functoolsmodule.c` (GH-129778)
Bénédikt Tran [Fri, 21 Feb 2025 14:08:56 +0000 (15:08 +0100)] 
gh-111178: fix UBSan failures in `Modules/_functoolsmodule.c` (GH-129778)

Fix UBSan failures for `keyobject`, `lru_list_elem`, `lru_cache_object`.
Suppress unused return values.
Change `_PyPartialObject_CAST` (from #124733) to `partialobject_CAST`
for consistency with the current style for these macros

8 months agogh-129363: Change regrtest sequential mode output (#129476)
Victor Stinner [Fri, 21 Feb 2025 13:55:32 +0000 (14:55 +0100)] 
gh-129363: Change regrtest sequential mode output (#129476)

First, write the test name without color. Then, write the test name
and the result with color. Each test is displayed twice.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
8 months agogh-129569: The function unicodedata.normalize() always returns built-in str (#129570)
Hizuru [Fri, 21 Feb 2025 13:51:13 +0000 (22:51 +0900)] 
gh-129569: The function unicodedata.normalize() always returns built-in str (#129570)

Co-authored-by: Victor Stinner <vstinner@python.org>
8 months agoAdd `.. versionadded` directive to `dis` CLI options (#130267)
sobolevn [Fri, 21 Feb 2025 12:59:17 +0000 (15:59 +0300)] 
Add `.. versionadded` directive to `dis` CLI options (#130267)

8 months agogh-127805: Clarify Formatter initialization in logging.rst. (GH-127850)
UV [Fri, 21 Feb 2025 07:10:04 +0000 (12:40 +0530)] 
gh-127805: Clarify Formatter initialization in logging.rst. (GH-127850)

8 months agoFix outdated reference link in collections module (gh-130349)
Redddy [Thu, 20 Feb 2025 23:58:58 +0000 (08:58 +0900)] 
Fix outdated reference link in collections module (gh-130349)

8 months agogh-130313: Avoid locking when clearing objects (#130126)
Dino Viehland [Thu, 20 Feb 2025 21:32:57 +0000 (13:32 -0800)] 
gh-130313: Avoid locking when clearing objects (#130126)

Avoid locking when clearing objects in the free-threaded build

8 months agogh-130052: Fix some exceptions on error paths in _testexternalinspection (#130053)
Sergey Miryanov [Thu, 20 Feb 2025 17:05:39 +0000 (22:05 +0500)] 
gh-130052: Fix some exceptions on error paths in _testexternalinspection (#130053)

Co-authored-by: Victor Stinner <vstinner@python.org>
8 months agogh-111924: Fix data races when swapping allocators (gh-130287)
Sam Gross [Thu, 20 Feb 2025 16:31:15 +0000 (11:31 -0500)] 
gh-111924: Fix data races when swapping allocators (gh-130287)

CPython current temporarily changes `PYMEM_DOMAIN_RAW` to the default
allocator during initialization and shutdown. The motivation is to
ensure that core runtime structures are allocated and freed using the
same allocator. However, modifying the current allocator changes global
state and is not thread-safe even with the GIL. Other threads may be
allocating or freeing objects use PYMEM_DOMAIN_RAW; they are not
required to hold the GIL to call PyMem_RawMalloc/PyMem_RawFree.

This adds new internal-only functions like `_PyMem_DefaultRawMalloc`
that aren't affected by calls to `PyMem_SetAllocator()`, so they're
appropriate for Python runtime initialization and finalization. Use
these calls in places where we previously swapped to the default raw
allocator.

8 months agogh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (#129839)
Collin Funk [Thu, 20 Feb 2025 16:02:33 +0000 (08:02 -0800)] 
gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (#129839)

Newer GCC versions accept both __attribute__((no_sanitize("undefined")))
and __attribute__((no_sanitize_undefined)) so check that the macro is
not already defined.

8 months agogh-46236: Document PyUnicode_RSplit, PyUnicode_Partition and PyUnicode_RPartition...
Marc Mueller [Thu, 20 Feb 2025 15:41:41 +0000 (16:41 +0100)] 
gh-46236: Document PyUnicode_RSplit, PyUnicode_Partition and PyUnicode_RPartition (#130191)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
8 months agogh-129269: Exclude everything in sys.path in `test_coverage_ignore` (gh-130133)
Sam Gross [Thu, 20 Feb 2025 15:13:44 +0000 (10:13 -0500)] 
gh-129269: Exclude everything in sys.path in `test_coverage_ignore` (gh-130133)

The `test_trace.test_coverage_ignore` test would fail if you had
`setuptools` installed, such as in `~/.local/lib/python3.xxx/site-packages/`.
Ignore everything in `sys.path` when running the test.

8 months ago[doc]: Update logging cookbook to mention domain socket configuration in a recipe...
Vinay Sajip [Thu, 20 Feb 2025 14:09:15 +0000 (14:09 +0000)] 
[doc]: Update logging cookbook to mention domain socket configuration in a recipe. (GH-130348)

8 months agogh-111178: fix UBSan failures in `Modules/_pickle.c` (#129787)
Bénédikt Tran [Thu, 20 Feb 2025 13:27:35 +0000 (14:27 +0100)] 
gh-111178: fix UBSan failures in `Modules/_pickle.c` (#129787)

Fix UBSan failures for `Pdata`, `PicklerObject`, `UnpicklerObject`, `PicklerMemoProxyObject`, `UnpicklerMemoProxyObject`

Indicate safe fast cast to avoid redundant future checks

Use semantically correct parameter names

8 months agogh-111178: fix UBSan failures in `Modules/overlapped.c` (GH-129786)
Bénédikt Tran [Thu, 20 Feb 2025 13:24:24 +0000 (14:24 +0100)] 
gh-111178: fix UBSan failures in `Modules/overlapped.c` (GH-129786)

Fix UBSan failures for `OverlappedObject`

8 months agogh-111178: fix UBSan failures in `Modules/_operator.c` (GH-129785)
Bénédikt Tran [Thu, 20 Feb 2025 13:21:55 +0000 (14:21 +0100)] 
gh-111178: fix UBSan failures in `Modules/_operator.c` (GH-129785)

Fix UBSan failures for `itemgetterobject`, `attrgetterobject`, `methodcallerobject`

Suppress unused return values

8 months agogh-129173: Use `_PyUnicodeError_GetParams` in `PyCodec_SurrogateEscapeErrors` (GH...
Bénédikt Tran [Thu, 20 Feb 2025 13:18:47 +0000 (14:18 +0100)] 
gh-129173: Use `_PyUnicodeError_GetParams` in `PyCodec_SurrogateEscapeErrors` (GH-129175)

8 months agogh-128863: Deprecate the private _PyUnicodeWriter API (#129245)
Victor Stinner [Thu, 20 Feb 2025 13:02:02 +0000 (14:02 +0100)] 
gh-128863: Deprecate the private _PyUnicodeWriter API (#129245)

Deprecate private C API functions:

* _PyUnicodeWriter_Init()
* _PyUnicodeWriter_Finish()
* _PyUnicodeWriter_Dealloc()
* _PyUnicodeWriter_WriteChar()
* _PyUnicodeWriter_WriteStr()
* _PyUnicodeWriter_WriteSubstring()
* _PyUnicodeWriter_WriteASCIIString()
* _PyUnicodeWriter_WriteLatin1String()

These functions are not deprecated in the internal C API (if the
Py_BUILD_CORE macro is defined).

8 months agogh-101100: Fix sphinx warnings in `readline.rst` (#130300)
Yuki Kobayashi [Thu, 20 Feb 2025 12:56:27 +0000 (21:56 +0900)] 
gh-101100: Fix sphinx warnings in `readline.rst` (#130300)

8 months agogh-130250: use support.swap_attr() in test and don't assume we're beginning with...
Irit Katriel [Thu, 20 Feb 2025 11:29:18 +0000 (11:29 +0000)] 
gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (#130342)

8 months agoFix some ctypes docs typos (GH-130307)
Alcaro [Thu, 20 Feb 2025 10:58:50 +0000 (11:58 +0100)] 
Fix some ctypes docs typos (GH-130307)

8 months agogh-127750: Restore inspect and pydoc support of singledispatchmethod (GH-130309)
Serhiy Storchaka [Thu, 20 Feb 2025 09:08:49 +0000 (11:08 +0200)] 
gh-127750: Restore inspect and pydoc support of singledispatchmethod (GH-130309)

The code is still flawed, because it does not recognize class and static
methods, and the first argument is not removed from the signature of
bound methods, but at least it does not worse than in 3.13 and older.

8 months agogh-69001: Convert links to more usable buttons (#129591)
Stan Ulbrych [Thu, 20 Feb 2025 08:30:57 +0000 (08:30 +0000)] 
gh-69001: Convert links to more usable buttons (#129591)

In Lib/idlelib/help_about.py, there are 2 links that are not underlined or colored, hence hard to tell that clicking works.  All buttons might get converted to colored and underlined links in the future.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
8 months agogh-130130: Clarify `hash=False` docs in `dataclasses.field` (#130324)
Sabfo [Thu, 20 Feb 2025 07:43:27 +0000 (09:43 +0200)] 
gh-130130: Clarify `hash=False` docs in `dataclasses.field` (#130324)

8 months agogh-130293: Ensure test__colorize will pass on dumb terminals. (#130333)
Russell Keith-Magee [Thu, 20 Feb 2025 06:49:18 +0000 (14:49 +0800)] 
gh-130293: Ensure test__colorize will pass on dumb terminals. (#130333)

Ensure colorize tests will run on dumb terminals (or environment with TERM=dumb set)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
8 months agogh-57537: Support breakpoints for zipimport modules on pdb (#130290)
Tian Gao [Thu, 20 Feb 2025 02:01:04 +0000 (21:01 -0500)] 
gh-57537: Support breakpoints for zipimport modules on pdb (#130290)

8 months agogh-130250: fix cleanup in test (impacts refleaks runs) (#130329)
Irit Katriel [Thu, 20 Feb 2025 01:37:30 +0000 (01:37 +0000)] 
gh-130250: fix cleanup in test (impacts refleaks runs) (#130329)

8 months agogh-130250: fix regression in traceback.print_last (#130318)
Irit Katriel [Wed, 19 Feb 2025 21:44:35 +0000 (21:44 +0000)] 
gh-130250: fix regression in traceback.print_last (#130318)

8 months agogh-122876: Fix "End of lines" typo (#125310)
za [Wed, 19 Feb 2025 19:16:38 +0000 (02:16 +0700)] 
gh-122876: Fix "End of lines" typo (#125310)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
8 months agogh-128396: Fix a crash when inline comprehension has the same local variable as the...
Tian Gao [Wed, 19 Feb 2025 17:11:17 +0000 (12:11 -0500)] 
gh-128396: Fix a crash when inline comprehension has the same local variable as the outside scope (#130235)

8 months agogh-130221: fix crash when accessing module state while interp is finalizing in asynci...
Kumar Aditya [Wed, 19 Feb 2025 16:37:56 +0000 (22:07 +0530)] 
gh-130221: fix crash when accessing module state while interp is finalizing in asyncio (#130245)

8 months agogh-129898: per-thread current task implementation in asyncio (#129899)
Kumar Aditya [Wed, 19 Feb 2025 16:34:49 +0000 (22:04 +0530)] 
gh-129898: per-thread current task implementation in asyncio (#129899)

Store the current running task on the thread state, it makes it thread safe for the free-threading build and while improving performance as there is no lock contention, this effectively makes it lock free.
When accessing the current task of the current running loop in current thread, no locking is required and can be acessed without locking.
In the rare case of accessing current task of a loop running in a different thread, the stop the world pauses is used in free-threading builds to stop all other running threads and find the task for the specified loop.

This also makes it easier for external introspection to find the current task, and now it will be always correct.

8 months agoRevert "Use ubuntu-22.04-arm image for Arm runners. (#129834)" (#130305)
Diego Russo [Wed, 19 Feb 2025 16:06:11 +0000 (16:06 +0000)] 
Revert "Use ubuntu-22.04-arm image for Arm runners. (#129834)" (#130305)

GitHub discovered it was an issue with the underlying hardware
and have migrated all the runners to a different arm sku (dpdsv5).

This reverts commit 80b9e79d84e835ecdb5a15c9ba73e44803ca9d32.

8 months agoGH-91079: Implement C stack limits using addresses, not counters. (GH-130007)
Mark Shannon [Wed, 19 Feb 2025 11:44:57 +0000 (11:44 +0000)] 
GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)

* Implement C recursion protection with limit pointers

* 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-111178: fix UBSan failures in `Modules/_datetimemodule.c` (GH-129774)
Bénédikt Tran [Wed, 19 Feb 2025 11:18:37 +0000 (12:18 +0100)] 
gh-111178: fix UBSan failures in `Modules/_datetimemodule.c` (GH-129774)

Add cast macros for date and time objects

Fix UBSan failures for `PyDateTime_Delta`, `PyDateTime_Date`, `PyDateTime_TZInfo`, `PyDateTime_TimeZone`, `PyDateTime_Time`, `PyDateTime_DateTime`, `PyDateTime_IsoCalendarDate`

Fix up naming

8 months agogh-111178: fix UBSan failures in `Modules/mmapmodule.c` (GH-129784)
Bénédikt Tran [Wed, 19 Feb 2025 11:02:32 +0000 (12:02 +0100)] 
gh-111178: fix UBSan failures in `Modules/mmapmodule.c` (GH-129784)

Fix UBSan failures for `mmap_object`

Use 'ignored' for NOARGS method and 'args' for others

8 months agogh-111178: fix UBSan failures in `Modules/itertoolsmodule.c` (GH-129780)
Bénédikt Tran [Wed, 19 Feb 2025 10:58:47 +0000 (11:58 +0100)] 
gh-111178: fix UBSan failures in `Modules/itertoolsmodule.c` (GH-129780)

8 months agogh-129107: make `bytearray` iterator thread safe (#130096)
Tomasz Pytel [Wed, 19 Feb 2025 10:12:45 +0000 (05:12 -0500)] 
gh-129107: make `bytearray` iterator thread safe (#130096)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
8 months agogh-115999: Make list and tuple iteration more thread-safe. (#128637)
T. Wouters [Wed, 19 Feb 2025 00:52:46 +0000 (16:52 -0800)] 
gh-115999: Make list and tuple iteration more thread-safe. (#128637)

Make tuple iteration more thread-safe, and actually test concurrent iteration of tuple, range and list. (This is prep work for enabling specialization of FOR_ITER in free-threaded builds.) The basic premise is:

Iterating over a shared iterable (list, tuple or range) should be safe, not involve data races, and behave like iteration normally does.

Using a shared iterator should not crash or involve data races, and should only produce items regular iteration would produce. It is not guaranteed to produce all items, or produce each item only once. (This is not the case for range iteration even after this PR.)

Providing stronger guarantees is possible for some of these iterators, but it's not always straight-forward and can significantly hamper the common case. Since iterators in general aren't shared between threads, and it's simply impossible to concurrently use many iterators (like generators), better to make sharing iterators without explicit synchronization clearly wrong.

Specific issues fixed in order to make the tests pass:

 - List iteration could occasionally fail an assertion when a shared list was shrunk and an item past the new end was retrieved concurrently. There's still some unsafety when deleting/inserting multiple items through for example slice assignment, which uses memmove/memcpy.

 - Tuple iteration could occasionally crash when the iterator's reference to the tuple was cleared on exhaustion. Like with list iteration, in free-threaded builds we can't safely and efficiently clear the iterator's reference to the iterable (doing it safely would mean extra, slow refcount operations), so just keep the iterable reference around.

8 months agoDocs: Upgrade Sphinx to 8.2 (#130171)
Adam Turner [Tue, 18 Feb 2025 23:45:02 +0000 (23:45 +0000)] 
Docs: Upgrade Sphinx to 8.2 (#130171)

8 months agogh-130094: Fix race conditions in `importlib` (gh-130101)
Sam Gross [Tue, 18 Feb 2025 23:02:42 +0000 (18:02 -0500)] 
gh-130094: Fix race conditions in `importlib` (gh-130101)

Entries may be added or removed from `sys.meta_path` concurrently. For
example, setuptools temporarily adds and removes the `distutils` finder from
the beginning of the list. The local copy ensures that we don't skip over any
entries.

Some packages modify `sys.modules` during import. For example, `collections`
inserts the entry for `collections.abc`  into `sys.modules` during import. We
need to ensure that we re-check `sys.modules` *after* the parent module is
fully initialized.

8 months agogh-124703: Add extra checks for pdb quit test (#130286)
Tian Gao [Tue, 18 Feb 2025 21:55:39 +0000 (16:55 -0500)] 
gh-124703: Add extra checks for pdb quit test (#130286)

8 months agogh-129515: Clarify syntax error messages for conditional expressions (#129880)
Sergey Miryanov [Tue, 18 Feb 2025 21:43:19 +0000 (02:43 +0500)] 
gh-129515: Clarify syntax error messages for conditional expressions (#129880)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
8 months agobpo-45325: Add a new 'p' parameter to Py_BuildValue to convert an integer into a...
Pablo Galindo Salgado [Tue, 18 Feb 2025 17:14:11 +0000 (17:14 +0000)] 
bpo-45325: Add a new 'p' parameter to Py_BuildValue to convert an integer into a Python bool (#28634)