]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
15 months agogh-57141: Make shallow argument to filecmp.dircmp keyword-only (#121767)
Jelle Zijlstra [Sun, 14 Jul 2024 22:53:32 +0000 (15:53 -0700)] 
gh-57141: Make shallow argument to filecmp.dircmp keyword-only (#121767)

It is our general practice to make new optional parameters keyword-only,
even if the existing parameters are all positional-or-keyword. Passing
this parameter as positional would look confusing and could be error-prone
if additional parameters are added in the future.

15 months agoGeneralize reusable Windows CI jobs (#121766)
Sviatoslav Sydorenko (Святослав Сидоренко) [Sun, 14 Jul 2024 21:22:35 +0000 (23:22 +0200)] 
Generalize reusable Windows CI jobs (#121766)

15 months agogh-121731: Fix mimalloc compile error on GNU/Hurd (#121732)
Samuel Thibault [Sun, 14 Jul 2024 16:50:25 +0000 (18:50 +0200)] 
gh-121731: Fix mimalloc compile error on GNU/Hurd (#121732)

15 months agogh-121621: Use PyMutex for writes to asyncio state (#121622)
Ken Jin [Sun, 14 Jul 2024 12:22:56 +0000 (20:22 +0800)] 
gh-121621: Use PyMutex for writes to asyncio state (#121622)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
15 months agogh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result (#121661)
sobolevn [Sun, 14 Jul 2024 11:20:40 +0000 (14:20 +0300)] 
gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result (#121661)

15 months agoFix cache restoration for Hypothesis CI job (#121756)
Sviatoslav Sydorenko (Святослав Сидоренко) [Sun, 14 Jul 2024 11:00:32 +0000 (13:00 +0200)] 
Fix cache restoration for Hypothesis CI job (#121756)

15 months agogh-121749: Fix discrepancy in docs for `PyModule_AddObjectRef` (GH-121750)
Dominic H [Sun, 14 Jul 2024 10:11:10 +0000 (12:11 +0200)] 
gh-121749: Fix discrepancy in docs for `PyModule_AddObjectRef` (GH-121750)

15 months agogh-121698 Emscripten: Use updated WebAssembly type reflection proposal (GH-121699)
Hood Chatham [Sun, 14 Jul 2024 09:25:09 +0000 (11:25 +0200)] 
gh-121698 Emscripten: Use updated WebAssembly type reflection proposal (GH-121699)

15 months agogh-121700 Emscripten trampolines not quite right since #106219 (GH-121701)
Hood Chatham [Sun, 14 Jul 2024 09:24:09 +0000 (11:24 +0200)] 
gh-121700 Emscripten trampolines not quite right since #106219 (GH-121701)

15 months agogh-121562: optimized hex_from_char (#121563)
Bruno Lima [Sun, 14 Jul 2024 09:05:35 +0000 (06:05 -0300)] 
gh-121562: optimized hex_from_char (#121563)

Performance improvement to `float.fromhex`: use a lookup table
for computing the hexadecimal value of a character, in place of the
previous switch-case construct. Patch by Bruno Lima.

15 months agogh-64308: Remove TestProgram from the unittest docs (GH-121675)
Jan Musílek [Sun, 14 Jul 2024 08:57:12 +0000 (10:57 +0200)] 
gh-64308: Remove TestProgram from the unittest docs (GH-121675)

15 months agogh-121708: Improve test coverage for `unittest.util` (GH-121713)
Tomas R [Sun, 14 Jul 2024 08:08:47 +0000 (10:08 +0200)] 
gh-121708: Improve test coverage for `unittest.util` (GH-121713)

16 months agogh-120642: Move _PyCode_CODE() to the internal C API (#121644)
Victor Stinner [Sat, 13 Jul 2024 21:07:49 +0000 (23:07 +0200)] 
gh-120642: Move _PyCode_CODE() to the internal C API (#121644)

Move _PyCode_CODE() and _PyCode_NBYTES() macros to the internal C API
since they use _Py_CODEUNIT which is only part of the internal C API.

16 months agogh-73159 Added clarifications in multiprocessing docs on that objects are pickled...
Ulrik Södergren [Sat, 13 Jul 2024 20:07:40 +0000 (22:07 +0200)] 
gh-73159 Added clarifications in multiprocessing docs on that objects are pickled. (GH-121686)

Added explicit comments about that objects are pickled when transmitted via multiprocessing queues and pipes.

16 months agogh-121651: Fix pdb header test (#121724)
Tian Gao [Sat, 13 Jul 2024 18:55:22 +0000 (11:55 -0700)] 
gh-121651: Fix pdb header test (#121724)

16 months agogh-121652: Handle `allocate_weakref` returning NULL (#121653)
Sam Gross [Sat, 13 Jul 2024 16:07:52 +0000 (12:07 -0400)] 
gh-121652: Handle `allocate_weakref` returning NULL (#121653)

The `allocate_weakref` may return NULL when out of memory. We need to
handle that case and propagate the error.

16 months agogh-121711: Set `-m asyncio` return_code to 1 for ENOTTY (#121714)
Milan Oberkirch [Sat, 13 Jul 2024 15:17:24 +0000 (17:17 +0200)] 
gh-121711: Set `-m asyncio` return_code to 1 for ENOTTY (#121714)

Set return_code to 1 for ENOTTY

16 months agogh-121657: Display correct error message for yield from outside of a function (GH...
Gregor [Sat, 13 Jul 2024 15:14:39 +0000 (17:14 +0200)] 
gh-121657: Display correct error message for yield from outside of a function (GH-121680)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
16 months agogh-120452: improve documentation about private name mangling (#120451)
Bénédikt Tran [Sat, 13 Jul 2024 14:45:18 +0000 (16:45 +0200)] 
gh-120452: improve documentation about private name mangling (#120451)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
16 months agogh-120823: Fix doc for ftplib.FTP.retrbinary() (GH-121697)
mirelagrigoras [Sat, 13 Jul 2024 14:16:26 +0000 (16:16 +0200)] 
gh-120823: Fix doc for ftplib.FTP.retrbinary() (GH-121697)

Co-authored-by: Mirela Andreea GRIGORAS <magrigoras@bitdefender.com>
16 months agogh-121605: Increase timeout in test_pyrepl.run_repl (#121606)
Sam Gross [Sat, 13 Jul 2024 13:54:28 +0000 (09:54 -0400)] 
gh-121605: Increase timeout in test_pyrepl.run_repl (#121606)

We also need to close the `slave_fd` earlier so that reading from
`master_fd` won't block forever when the subprocess finishes.

16 months agogh-121671: Increase test coverage of `ast.get_docstring` (GH-121674)
Tomas R [Sat, 13 Jul 2024 12:59:15 +0000 (14:59 +0200)] 
gh-121671: Increase test coverage of `ast.get_docstring` (GH-121674)

Increase test coverage for `ast.get_docstring`

16 months agogh-96765: Update ConfigParser.read() docs with multi-file read example (#121664)
Timon Viola [Sat, 13 Jul 2024 12:47:05 +0000 (14:47 +0200)] 
gh-96765: Update ConfigParser.read() docs with multi-file read example (#121664)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
16 months agogh-121499: Fix multi-line history rendering in the REPL (#121531)
Pablo Galindo Salgado [Sat, 13 Jul 2024 10:54:10 +0000 (12:54 +0200)] 
gh-121499: Fix multi-line history rendering in the REPL (#121531)

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
16 months agogh-121609: Fix pasting of characters containing unicode character joiner (#121667)
Marta Gómez Macías [Sat, 13 Jul 2024 10:44:18 +0000 (12:44 +0200)] 
gh-121609: Fix pasting of characters containing unicode character joiner (#121667)

16 months agogh-121153: Fix some errors with use of _PyLong_CompactValue() (GH-121154)
Serhiy Storchaka [Sat, 13 Jul 2024 10:40:44 +0000 (13:40 +0300)] 
gh-121153: Fix some errors with use of _PyLong_CompactValue() (GH-121154)

* The result has type Py_ssize_t, not intptr_t.
* Type cast between unsigned and signdet integer types should be explicit.
* Downcasting should be explicit.
* Fix integer overflow check in sum().

16 months agogh-99242 Ignore error when running regression tests under certain conditions. (GH...
Bas Bloemsaat [Sat, 13 Jul 2024 09:52:08 +0000 (11:52 +0200)] 
gh-99242 Ignore error when running regression tests under certain conditions. (GH-121663)

Co-Authored-By: Kevin Diem <kg.diem@gmail.com>
16 months agogh-121497: Make Pyrepl respect correctly the history with input hook set (#121498)
Pablo Galindo Salgado [Sat, 13 Jul 2024 09:42:14 +0000 (11:42 +0200)] 
gh-121497: Make Pyrepl respect correctly the history with input hook set (#121498)

16 months agogh-95144: Improve error message of `... in None` (GH-119888)
Zachary Ware [Fri, 12 Jul 2024 16:34:17 +0000 (11:34 -0500)] 
gh-95144: Improve error message of `... in None` (GH-119888)

16 months agoUpdate retroactive comments from GH-117741 (segfault in `FutureIter_dealloc`) (GH...
Savannah Ostrowski [Fri, 12 Jul 2024 08:34:30 +0000 (01:34 -0700)] 
Update retroactive comments from GH-117741 (segfault in `FutureIter_dealloc`) (GH-121638)

Address comments

16 months agogh-121103: Put free-threaded libraries in `lib/python3.14t` (#121293)
Sam Gross [Thu, 11 Jul 2024 20:21:37 +0000 (16:21 -0400)] 
gh-121103: Put free-threaded libraries in `lib/python3.14t` (#121293)

On POSIX systems, excluding macOS framework installs, the lib directory
for the free-threaded build now includes a "t" suffix to avoid conflicts
with a co-located default build installation.

16 months agogh-117482: Fix Builtin Types Slot Wrappers (gh-121602)
Eric Snow [Thu, 11 Jul 2024 20:20:14 +0000 (14:20 -0600)] 
gh-117482: Fix Builtin Types Slot Wrappers (gh-121602)

When builtin static types are initialized for a subinterpreter, various "tp" slots have already been inherited (for the main interpreter).  This was interfering with the logic in add_operators() (in Objects/typeobject.c), causing a wrapper to get created when it shouldn't.  This change fixes that by preserving the original data from the static type struct and checking that.

16 months agogh-121332: Make AST node constructor check _attributes instead of hardcoding attribut...
Jelle Zijlstra [Thu, 11 Jul 2024 14:34:53 +0000 (07:34 -0700)] 
gh-121332: Make AST node constructor check _attributes instead of hardcoding attributes (#121334)

16 months agogh-121592: Make select.poll() and related objects thread-safe (#121594)
Sam Gross [Thu, 11 Jul 2024 14:21:09 +0000 (10:21 -0400)] 
gh-121592: Make select.poll() and related objects thread-safe (#121594)

This makes select.poll() and kqueue() objects thread-safe in the
free-threaded build. Note that calling close() concurrently with other
functions is still not thread-safe due to races on file descriptors
(gh-121544).

16 months agogh-121615: Improve `module.rst` C-API docs with better error descriptions (#121616)
sobolevn [Thu, 11 Jul 2024 08:57:22 +0000 (11:57 +0300)] 
gh-121615: Improve `module.rst` C-API docs with better error descriptions (#121616)

16 months agogh-121450: Make inline breakpoints use the most recent pdb instance (#121451)
Tian Gao [Thu, 11 Jul 2024 02:54:27 +0000 (19:54 -0700)] 
gh-121450: Make inline breakpoints use the most recent pdb instance (#121451)

16 months agogh-121554: remove unnecessary internal functions in compile.c (#121555)
Irit Katriel [Wed, 10 Jul 2024 22:48:37 +0000 (23:48 +0100)] 
gh-121554: remove unnecessary internal functions in compile.c (#121555)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
16 months agogh-119786: fix broken links in docs and comment (#121601)
Irit Katriel [Wed, 10 Jul 2024 21:59:14 +0000 (22:59 +0100)] 
gh-119786: fix broken links in docs and comment (#121601)

16 months agogh-121596: Fix Sharing Interpreter Channels (gh-121597)
Eric Snow [Wed, 10 Jul 2024 21:31:09 +0000 (15:31 -0600)] 
gh-121596: Fix Sharing Interpreter Channels (gh-121597)

This fixes a mistake in gh-113012 and adds a test that verifies the fix.

16 months agogh-117657: Remove TSAN suppressions for _abc.c (#121508)
Sam Gross [Wed, 10 Jul 2024 21:08:10 +0000 (17:08 -0400)] 
gh-117657: Remove TSAN suppressions for _abc.c (#121508)

The functions look thread-safe and I haven't seen any warnings issued
when running the tests locally.

16 months agogh-117657: Fix TSan race in _PyDict_CheckConsistency (#121551)
Sam Gross [Wed, 10 Jul 2024 18:04:12 +0000 (14:04 -0400)] 
gh-117657: Fix TSan race in _PyDict_CheckConsistency (#121551)

The only remaining race in dictobject.c was in _PyDict_CheckConsistency
when the dictionary has shared keys.

16 months agogh-120198: Stop the world when setting __class__ on free-threaded build (GH-120672)
Ken Jin [Wed, 10 Jul 2024 18:02:08 +0000 (02:02 +0800)] 
gh-120198: Stop the world when setting __class__ on free-threaded build (GH-120672)

16 months agogh-121460: Skip freeing unallocated arenas (gh-121491)
Stefano Rivera [Wed, 10 Jul 2024 16:40:55 +0000 (09:40 -0700)] 
gh-121460: Skip freeing unallocated arenas (gh-121491)

`munmap(NULL)` is not noop, like `free(NULL)` is.

Fixes an observed testsuite hang on 32-bit ARM systems.

16 months agogh-121404: remove some accesses to compiler internals from codegen functions (#121538)
Irit Katriel [Wed, 10 Jul 2024 16:09:45 +0000 (17:09 +0100)] 
gh-121404: remove some accesses to compiler internals from codegen functions (#121538)

16 months agogh-107851: Fix spurious failures in fcntl eintr tests (#121556)
Sam Gross [Wed, 10 Jul 2024 14:36:52 +0000 (10:36 -0400)] 
gh-107851: Fix spurious failures in fcntl eintr tests (#121556)

On heavily loaded machines, the subprocess may finish its sleep before
the parent process manages to synchronize with it via a failed lock.

This leads to errors like:

  Exception: failed to sync child in 300.3 sec

Use pipes instead to mutually synchronize between parent and child.

16 months agogh-89364: Export PySignal_SetWakeupFd() function (#121537)
Victor Stinner [Wed, 10 Jul 2024 13:47:08 +0000 (15:47 +0200)] 
gh-89364: Export PySignal_SetWakeupFd() function (#121537)

Export the PySignal_SetWakeupFd() function. Previously, the function
was documented but it couldn't be used in 3rd party code.

16 months agogh-121567: Improve `slice` C-API docs by mentioning exceptions (#121568)
sobolevn [Wed, 10 Jul 2024 10:56:44 +0000 (13:56 +0300)] 
gh-121567: Improve `slice` C-API docs by mentioning exceptions (#121568)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
16 months agogh-121547: deduplicate the code of const_cache update functions (#121548)
Irit Katriel [Wed, 10 Jul 2024 10:34:54 +0000 (11:34 +0100)] 
gh-121547: deduplicate the code of const_cache update functions (#121548)

16 months agogh-121571: Do not use `EnvironmentError` in tests, use `OSError` instead (#121572)
sobolevn [Wed, 10 Jul 2024 10:11:46 +0000 (13:11 +0300)] 
gh-121571: Do not use `EnvironmentError` in tests, use `OSError` instead (#121572)

16 months agoImprove zipimport tests (GH-121535)
Serhiy Storchaka [Wed, 10 Jul 2024 08:29:03 +0000 (11:29 +0300)] 
Improve zipimport tests (GH-121535)

16 months agoGH-121439: Allow PyTupleObjects with an ob_size of 20 in the free_list to be reused...
satori1995 [Wed, 10 Jul 2024 07:48:25 +0000 (15:48 +0800)] 
GH-121439: Allow PyTupleObjects with an ob_size of 20 in the free_list to be reused (gh-121428)

16 months agoGH-121521: Detect when wasmtime is not installed in `Tools/wasm/wasi.py` (GH-121522) 105081/head
Brett Cannon [Tue, 9 Jul 2024 22:08:01 +0000 (15:08 -0700)] 
GH-121521: Detect when wasmtime is not installed in `Tools/wasm/wasi.py` (GH-121522)

16 months agoGH-120372: Switch to wasmtime 22 (GH-121523)
Brett Cannon [Tue, 9 Jul 2024 22:02:25 +0000 (15:02 -0700)] 
GH-120372: Switch to wasmtime 22 (GH-121523)

Along the way, make the cache key in GitHub Actions for `config.cache` be more robust in the face of potential env var changes from `Tools/wasm/wasi.py`.

16 months agogh-117657: Skip test when running under TSan (GH-121549)
Sam Gross [Tue, 9 Jul 2024 21:12:45 +0000 (17:12 -0400)] 
gh-117657: Skip test when running under TSan (GH-121549)

The ProcessPoolForkserver combined with resource_tracker starts a thread
after forking, which is not supported by TSan.

Also skip test_multiprocessing_fork for the same reason

16 months agogh-117657: Fix TSAN races in setobject.c (#121511)
Sam Gross [Tue, 9 Jul 2024 16:11:43 +0000 (12:11 -0400)] 
gh-117657: Fix TSAN races in setobject.c (#121511)

The `used` field must be written using atomic stores because `set_len`
and iterators may access the field concurrently without holding the
per-object lock.

16 months agogh-121533: Improve `PyCell_[Get,Set]` docs: mention the exceptions (#121534)
sobolevn [Tue, 9 Jul 2024 15:47:35 +0000 (18:47 +0300)] 
gh-121533: Improve `PyCell_[Get,Set]` docs: mention the exceptions (#121534)

Co-authored-by: Victor Stinner <vstinner@python.org>
16 months agoDocs: fix typo and duplicate word in configure.rst (#121410)
Rafael Fontenelle [Tue, 9 Jul 2024 12:24:37 +0000 (09:24 -0300)] 
Docs: fix typo and duplicate word in configure.rst (#121410)

16 months agoGH-118926: Better distinguish between pointer and arrays in interpreter generator...
Mark Shannon [Tue, 9 Jul 2024 10:33:56 +0000 (11:33 +0100)] 
GH-118926: Better distinguish between pointer and arrays in interpreter generator (GH-121496)

16 months agogh-121333: Clarify what is the default executor for asyncio.run_in_executor (#121335)
AN Long [Tue, 9 Jul 2024 09:22:07 +0000 (17:22 +0800)] 
gh-121333: Clarify what is the default executor for asyncio.run_in_executor (#121335)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
16 months agogh-121110: Fix Extension Module Tests Under Py_TRACE_REFS Builds (gh-121503)
Eric Snow [Mon, 8 Jul 2024 21:10:00 +0000 (15:10 -0600)] 
gh-121110: Fix Extension Module Tests Under Py_TRACE_REFS Builds (gh-121503)

The change in gh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't.  We fix that here.  Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests.

16 months agogh-121018: Fix typo in NEWS entry (#121510)
Sam Gross [Mon, 8 Jul 2024 20:44:56 +0000 (16:44 -0400)] 
gh-121018: Fix typo in NEWS entry (#121510)

16 months agoNEWS: Fix Sphinx warnings and increase threshold for new news nits (#121482)
Hugo van Kemenade [Mon, 8 Jul 2024 20:30:05 +0000 (14:30 -0600)] 
NEWS: Fix Sphinx warnings and increase threshold for new news nits (#121482)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
16 months agogh-121404: remove direct accesses to u_private from codegen functions (#121500)
Irit Katriel [Mon, 8 Jul 2024 20:02:01 +0000 (21:02 +0100)] 
gh-121404: remove direct accesses to u_private from codegen functions (#121500)

16 months agogh-121368: Fix seq lock memory ordering in _PyType_Lookup (#121388)
Sam Gross [Mon, 8 Jul 2024 18:52:07 +0000 (14:52 -0400)] 
gh-121368: Fix seq lock memory ordering in _PyType_Lookup (#121388)

The `_PySeqLock_EndRead` function needs an acquire fence to ensure that
the load of the sequence happens after any loads within the read side
critical section. The missing fence can trigger bugs on macOS arm64.

Additionally, we need a release fence in `_PySeqLock_LockWrite` to
ensure that the sequence update is visible before any modifications to
the cache entry.

16 months agogh-121487: Fix deprecation warning for ATOMIC_VAR_INIT in mimalloc (gh-121488)
Marc Mueller [Mon, 8 Jul 2024 18:32:30 +0000 (20:32 +0200)] 
gh-121487: Fix deprecation warning for ATOMIC_VAR_INIT in mimalloc (gh-121488)

16 months agoGH-119169: Simplify `os.walk()` exception handling (#121435)
Barney Gale [Mon, 8 Jul 2024 16:41:01 +0000 (17:41 +0100)] 
GH-119169: Simplify `os.walk()` exception handling (#121435)

Handle errors from `os.scandir()` and `ScandirIterator` similarly, which
lets us loop over directory entries with `for`.

16 months agogh-121374: Correct docstrings in `_interpchannels` (gh-121418)
Max Muoto [Mon, 8 Jul 2024 16:32:17 +0000 (11:32 -0500)] 
gh-121374: Correct docstrings in `_interpchannels` (gh-121418)

16 months agoGH-121012: Set index to -1 when list iterators become exhausted in tier 2 (GH-121483)
Mark Shannon [Mon, 8 Jul 2024 13:20:13 +0000 (14:20 +0100)] 
GH-121012: Set index to -1 when list iterators become exhausted in tier 2 (GH-121483)

16 months agogh-121338: Remove #pragma optimize (#121340)
Michael Droettboom [Mon, 8 Jul 2024 12:48:42 +0000 (08:48 -0400)] 
gh-121338: Remove #pragma optimize (#121340)

16 months agogh-108297: Update crashers README for test_crashers removal (#121475)
Alyssa Coghlan [Mon, 8 Jul 2024 05:24:31 +0000 (15:24 +1000)] 
gh-108297: Update crashers README for test_crashers removal (#121475)

Update Lib/test/crashers/README for test_crashers removal

16 months agogh-121461: Fix os.path.normpath documentation indentation (#121466)
CBerJun [Mon, 8 Jul 2024 03:51:03 +0000 (23:51 -0400)] 
gh-121461: Fix os.path.normpath documentation indentation (#121466)

16 months agogh-121467: Fix makefile to include mimalloc headers (#121469)
Marc Mueller [Mon, 8 Jul 2024 00:45:21 +0000 (02:45 +0200)] 
gh-121467: Fix makefile to include mimalloc headers (#121469)

16 months agoFix sphinx reference target (#121470)
Shantanu [Mon, 8 Jul 2024 00:18:28 +0000 (17:18 -0700)] 
Fix sphinx reference target (#121470)

This was introduced in https://github.com/python/cpython/pull/121164
and appears to be causing test failures on main

16 months agoGH-73991: Fix "Operation not supported" on Fedora buildbot. (#121444)
Barney Gale [Sun, 7 Jul 2024 16:27:52 +0000 (17:27 +0100)] 
GH-73991: Fix "Operation not supported" on Fedora buildbot. (#121444)

Follow-up to #120806. Use `os_helper.skip_unless_xattr` to skip testing
xattr preservation when unsupported.

16 months agoAdd Fidget-Spinner to stackrefs CODEOWNERS (GH-121455)
Ken Jin [Sun, 7 Jul 2024 13:45:06 +0000 (21:45 +0800)] 
Add Fidget-Spinner to stackrefs CODEOWNERS (GH-121455)

16 months agogh-121351: Skip test_not_wiping_history_file() if no readline (#121422)
Sergey B Kirpichev [Sat, 6 Jul 2024 22:53:54 +0000 (01:53 +0300)] 
gh-121351: Skip test_not_wiping_history_file() if no readline (#121422)

16 months agogh-119909: Fix ``NameError`` in ``asyncio`` REPL (#121341)
Kirill Podoprigora [Sat, 6 Jul 2024 20:49:33 +0000 (23:49 +0300)] 
gh-119909: Fix ``NameError`` in ``asyncio`` REPL (#121341)

16 months agoRegen ``Doc/requirements-oldest-sphinx.txt`` (#121437)
Kirill Podoprigora [Sat, 6 Jul 2024 18:04:41 +0000 (21:04 +0300)] 
Regen ``Doc/requirements-oldest-sphinx.txt`` (#121437)

regen dependencies

16 months ago[docs] fix a Sphinx directive in `c-api/object.rst` (#121430)
Bénédikt Tran [Sat, 6 Jul 2024 17:57:26 +0000 (19:57 +0200)] 
[docs] fix a Sphinx directive in `c-api/object.rst` (#121430)

16 months agoGH-73991: Support preserving metadata in `pathlib.Path.copy()` (#120806)
Barney Gale [Sat, 6 Jul 2024 16:18:39 +0000 (17:18 +0100)] 
GH-73991: Support preserving metadata in `pathlib.Path.copy()` (#120806)

Add *preserve_metadata* keyword-only argument to `pathlib.Path.copy()`, defaulting to false. When set to true, we copy timestamps, permissions, extended attributes and flags where available, like `shutil.copystat()`. The argument has no effect on Windows, where metadata is always copied.

Internally (in the pathlib ABCs), path types gain `_readable_metadata` and `_writable_metadata` attributes. These sets of strings describe what kinds of metadata can be retrieved and stored. We take an intersection of `source._readable_metadata` and `target._writable_metadata` to minimise reads/writes. A new `_read_metadata()` method accepts a set of metadata keys and returns a dict with those keys, and a new `_write_metadata()` method accepts a dict of metadata. We *might* make these public in future, but it's hard to justify while the ABCs are still private.

16 months agogh-121359: Run test_pyrepl in isolated mode (#121414)
Victor Stinner [Fri, 5 Jul 2024 20:30:08 +0000 (22:30 +0200)] 
gh-121359: Run test_pyrepl in isolated mode (#121414)

run_repl() now pass the -I option (isolated mode) to Python if the
'env' parameter is not set.

16 months agoUpdate example of str.split, bytes.split (#121287)
Yuxin Wu [Fri, 5 Jul 2024 20:08:29 +0000 (13:08 -0700)] 
Update example of str.split, bytes.split (#121287)

In `{str,bytes}.strip(chars)`, multiple characters are not treated as a
prefix/suffix, but as individual characters. This may make users confuse
whether `split` has similar behavior.
Users may incorrectly expect that
`'Good morning, John.'.split(', .') == ['Good', 'morning', 'John']`

Adding a bit of clarification in the doc.

Co-authored-by: Yuxin Wu <ppwwyyxx@users.noreply.github.com>
16 months agogh-121288: Make error message for index() methods consistent (GH-121395)
Serhiy Storchaka [Fri, 5 Jul 2024 17:50:45 +0000 (20:50 +0300)] 
gh-121288: Make error message for index() methods consistent (GH-121395)

Make error message for index() methods consistent

Remove the repr of the searched value (which can be arbitrary large)
from ValueError messages for list.index(), range.index(), deque.index(),
deque.remove() and ShareableList.index().  Make the error messages
consistent with error messages for other index() and remove()
methods.

16 months agoFixed regenerating files in a checkout path with spaces (GH-121384)
AraHaan [Fri, 5 Jul 2024 16:33:52 +0000 (12:33 -0400)] 
Fixed regenerating files in a checkout path with spaces (GH-121384)

16 months agogh-121149: improve accuracy of builtin sum() for complex inputs (gh-121176)
Sergey B Kirpichev [Fri, 5 Jul 2024 15:01:05 +0000 (18:01 +0300)] 
gh-121149: improve accuracy of builtin sum() for complex inputs (gh-121176)

16 months agogh-59110: Fix a debug output for implicit directories (GH-121375)
Serhiy Storchaka [Fri, 5 Jul 2024 08:44:07 +0000 (11:44 +0300)] 
gh-59110: Fix a debug output for implicit directories (GH-121375)

16 months agogh-121390: tracemalloc: Fix tracebacks memory leak (#121391)
Josh Brobst [Fri, 5 Jul 2024 06:39:48 +0000 (02:39 -0400)] 
gh-121390: tracemalloc: Fix tracebacks memory leak (#121391)

The tracemalloc_tracebacks hash table has traceback keys and NULL
values, but its destructors do not reflect this -- key_destroy_func is
NULL while value_destroy_func is raw_free. Swap these to free the
traceback keys instead.

16 months agogh-90437: Fix __main__.py documentation wording (GH-116309)
Ali Tavallaie [Thu, 4 Jul 2024 22:49:14 +0000 (02:19 +0330)] 
gh-90437: Fix __main__.py documentation wording (GH-116309)

Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Frank Dana <ferdnyc@gmail.com>
16 months agogh-121084: Fix test_typing random leaks (#121360)
Victor Stinner [Thu, 4 Jul 2024 17:38:30 +0000 (19:38 +0200)] 
gh-121084: Fix test_typing random leaks (#121360)

Clear typing ABC caches when running tests for refleaks (-R option):
call _abc_caches_clear() on typing abstract classes and their
subclasses.

16 months agogh-106597: Remove unnecessary CFrame offsets (#121369)
Gabriele N. Tornetta [Thu, 4 Jul 2024 17:28:23 +0000 (18:28 +0100)] 
gh-106597: Remove unnecessary CFrame offsets (#121369)

16 months agogh-59110: zipimport: support namespace packages when no directory entry exists (GH...
Serhiy Storchaka [Thu, 4 Jul 2024 15:04:24 +0000 (18:04 +0300)] 
gh-59110: zipimport: support namespace packages when no directory entry exists (GH-121233)

16 months agogh-118507: Amend news entry to mention ntpath.isfile bugfix (GH-120817)
Nice Zombies [Thu, 4 Jul 2024 14:56:06 +0000 (16:56 +0200)] 
gh-118507: Amend news entry to mention ntpath.isfile bugfix (GH-120817)

16 months agogh-121272: move async for/with validation from compiler to symtable (#121361)
Irit Katriel [Thu, 4 Jul 2024 13:47:21 +0000 (14:47 +0100)] 
gh-121272: move async for/with validation from compiler to symtable (#121361)

16 months agogh-121355: Fix incorrect word in simple_stmts.rst (#121356)
Jongbum Won [Thu, 4 Jul 2024 13:34:34 +0000 (22:34 +0900)] 
gh-121355: Fix incorrect word in simple_stmts.rst (#121356)

16 months agogh-120754: Update estimated_size in C truncate (#121357)
Cody Maloney [Thu, 4 Jul 2024 12:59:18 +0000 (05:59 -0700)] 
gh-120754: Update estimated_size in C truncate (#121357)

Sometimes a large file is truncated (test_largefile). While
estimated_size is used as a estimate (the read will stil get the number
of bytes in the file), that it is much larger than the actual size of
data can result in a significant over allocation and sometimes lead to
a MemoryError / running out of memory.

This brings the C implementation to match the Python _pyio
implementation.

16 months agogh-121352: use _Py_SourceLocation in symtable (#121353)
Irit Katriel [Thu, 4 Jul 2024 10:28:44 +0000 (11:28 +0100)] 
gh-121352: use _Py_SourceLocation in symtable (#121353)

16 months agogh-120754: Reduce system calls in full-file FileIO.readall() case (#120755)
Cody Maloney [Thu, 4 Jul 2024 07:17:00 +0000 (00:17 -0700)] 
gh-120754: Reduce system calls in full-file FileIO.readall() case (#120755)

This reduces the system call count of a simple program[0] that reads all
the `.rst` files in Doc by over 10% (5706 -> 4734 system calls on my
linux system, 5813 -> 4875 on my macOS)

This reduces the number of `fstat()` calls always and seek calls most
the time. Stat was always called twice, once at open (to error early on
directories), and a second time to get the size of the file to be able
to read the whole file in one read. Now the size is cached with the
first call.

The code keeps an optimization that if the user had previously read a
lot of data, the current position is subtracted from the number of bytes
to read. That is somewhat expensive so only do it on larger files,
otherwise just try and read the extra bytes and resize the PyBytes as
needeed.

I built a little test program to validate the behavior + assumptions
around relative costs and then ran it under `strace` to get a log of the
system calls. Full samples below[1].

After the changes, this is everything in one `filename.read_text()`:

```python3
openat(AT_FDCWD, "cpython/Doc/howto/clinic.rst", O_RDONLY|O_CLOEXEC) = 3`
fstat(3, {st_mode=S_IFREG|0644, st_size=343, ...}) = 0`
ioctl(3, TCGETS, 0x7ffdfac04b40)        = -1 ENOTTY (Inappropriate ioctl for device)
lseek(3, 0, SEEK_CUR)                   = 0
read(3, ":orphan:\n\n.. This page is retain"..., 344) = 343
read(3, "", 1)                          = 0
close(3)                                = 0
```

This does make some tradeoffs
1. If the file size changes between open() and readall(), this will
still get all the data but might have more read calls.
2. I experimented with avoiding the stat + cached result for small files
in general, but on my dev workstation at least that tended to reduce
performance compared to using the fstat().

[0]

```python3
from pathlib import Path

nlines = []
for filename in Path("cpython/Doc").glob("**/*.rst"):
    nlines.append(len(filename.read_text()))
```

[1]
Before small file:

```
openat(AT_FDCWD, "cpython/Doc/howto/clinic.rst", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=343, ...}) = 0
ioctl(3, TCGETS, 0x7ffe52525930)        = -1 ENOTTY (Inappropriate ioctl for device)
lseek(3, 0, SEEK_CUR)                   = 0
lseek(3, 0, SEEK_CUR)                   = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=343, ...}) = 0
read(3, ":orphan:\n\n.. This page is retain"..., 344) = 343
read(3, "", 1)                          = 0
close(3)                                = 0
```

After small file:

```
openat(AT_FDCWD, "cpython/Doc/howto/clinic.rst", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=343, ...}) = 0
ioctl(3, TCGETS, 0x7ffdfac04b40)        = -1 ENOTTY (Inappropriate ioctl for device)
lseek(3, 0, SEEK_CUR)                   = 0
read(3, ":orphan:\n\n.. This page is retain"..., 344) = 343
read(3, "", 1)                          = 0
close(3)                                = 0
```

Before large file:

```
openat(AT_FDCWD, "cpython/Doc/c-api/typeobj.rst", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=133104, ...}) = 0
ioctl(3, TCGETS, 0x7ffe52525930)        = -1 ENOTTY (Inappropriate ioctl for device)
lseek(3, 0, SEEK_CUR)                   = 0
lseek(3, 0, SEEK_CUR)                   = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=133104, ...}) = 0
read(3, ".. highlight:: c\n\n.. _type-struc"..., 133105) = 133104
read(3, "", 1)                          = 0
close(3)                                = 0
```

After large file:

```
openat(AT_FDCWD, "cpython/Doc/c-api/typeobj.rst", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=133104, ...}) = 0
ioctl(3, TCGETS, 0x7ffdfac04b40)        = -1 ENOTTY (Inappropriate ioctl for device)
lseek(3, 0, SEEK_CUR)                   = 0
lseek(3, 0, SEEK_CUR)                   = 0
read(3, ".. highlight:: c\n\n.. _type-struc"..., 133105) = 133104
read(3, "", 1)                          = 0
close(3)                                = 0
```

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
16 months agogh-121141: add support for `copy.replace` to AST nodes (#121162)
Bénédikt Tran [Thu, 4 Jul 2024 03:10:54 +0000 (05:10 +0200)] 
gh-121141: add support for `copy.replace` to AST nodes (#121162)

16 months agogh-117983: Defer import of threading for lazy module loading (#120233)
Chris Markiewicz [Wed, 3 Jul 2024 20:50:46 +0000 (16:50 -0400)] 
gh-117983: Defer import of threading for lazy module loading (#120233)

As noted in gh-117983, the import importlib.util can be triggered at
interpreter startup under some circumstances, so adding threading makes
it a potentially obligatory load.
Lazy loading is not used in the stdlib, so this removes an unnecessary
load for the majority of users and slightly increases the cost of the
first lazily loaded module.

An obligatory threading load breaks gevent, which monkeypatches the
stdlib. Although unsupported, there doesn't seem to be an offsetting
benefit to breaking their use case.

For reference, here are benchmarks for the current main branch:

```
❯ hyperfine -w 8 './python -c "import importlib.util"'
Benchmark 1: ./python -c "import importlib.util"
  Time (mean ± σ):       9.7 ms ±   0.7 ms    [User: 7.7 ms, System: 1.8 ms]
  Range (min … max):     8.4 ms …  13.1 ms    313 runs
```

And with this patch:

```
❯ hyperfine -w 8 './python -c "import importlib.util"'
Benchmark 1: ./python -c "import importlib.util"
  Time (mean ± σ):       8.4 ms ±   0.7 ms    [User: 6.8 ms, System: 1.4 ms]
  Range (min … max):     7.2 ms …  11.7 ms    352 runs
```

Compare to:

```
❯ hyperfine -w 8 './python -c pass'
Benchmark 1: ./python -c pass
  Time (mean ± σ):       7.6 ms ±   0.6 ms    [User: 5.9 ms, System: 1.6 ms]
  Range (min … max):     6.7 ms …  11.3 ms    390 runs
```

This roughly halves the import time of importlib.util.

16 months agogh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (#118725)
Tian Gao [Wed, 3 Jul 2024 18:30:20 +0000 (11:30 -0700)] 
gh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (#118725)