]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
7 months agogh-131032: Add support.linked_to_musl() function (#131071)
Victor Stinner [Thu, 13 Mar 2025 09:33:46 +0000 (10:33 +0100)] 
gh-131032: Add support.linked_to_musl() function (#131071)

Skip test_math.test_fma_zero_result() if Python is linked to the musl
C library.

7 months agogh-111178: Change Argument Clinic signature for `@staticmethod` (#131157) (#131159)
Victor Stinner [Thu, 13 Mar 2025 09:22:58 +0000 (10:22 +0100)] 
gh-111178: Change Argument Clinic signature for `@staticmethod` (#131157) (#131159)

Use "PyObject*", instead of "void*", for `@staticmethod` functions to
fix an undefined behavior.

7 months agogh-130940: Modify default behavior of `PyConfig.use_system_logger` to enable on iOS...
Russell Keith-Magee [Thu, 13 Mar 2025 06:28:49 +0000 (14:28 +0800)] 
gh-130940: Modify default behavior of `PyConfig.use_system_logger` to enable on iOS (#131172)

Modify default behavior of use_system_log to enable on iOS.

7 months agoRemove vestigial code in socketmodule.c for Mac OS X 10.1 (#131090)
Max Bachmann [Thu, 13 Mar 2025 04:13:07 +0000 (05:13 +0100)] 
Remove vestigial code in socketmodule.c for Mac OS X 10.1 (#131090)

7 months agogh-127503: Improve tracebacks on Emscripten when there is a trap (#131158)
Hood Chatham [Thu, 13 Mar 2025 00:28:15 +0000 (01:28 +0100)] 
gh-127503: Improve tracebacks on Emscripten when there is a trap (#131158)

Modifies the behavior of the interpreter on crash under Emscripten:
1. No Python traceback shown on segfault/trap
2. The JavaScript source line is shown

The JavaScript source line is super long and completely unenlightening,
whereas the Python traceback is very helpful.

7 months agogh-126835: Avoid creating unnecessary tuple when looking for constant sequence during...
Yan Yanchii [Wed, 12 Mar 2025 21:45:54 +0000 (22:45 +0100)] 
gh-126835: Avoid creating unnecessary tuple when looking for constant sequence during constant folding (#131054)

7 months agogh-131123: Support completion in `pdb` for convenience variable attributes (#131124)
Tian Gao [Wed, 12 Mar 2025 21:23:53 +0000 (17:23 -0400)] 
gh-131123: Support completion in `pdb` for convenience variable attributes (#131124)

7 months agogh-131045: [Enum] fix flag containment checks when using values (GH-131053)
Ethan Furman [Wed, 12 Mar 2025 19:10:47 +0000 (12:10 -0700)] 
gh-131045: [Enum] fix flag containment checks when using values (GH-131053)

Check would fail if value would create a pseudo-member, but that member
had not yet been created.  We now attempt to create a pseudo-member for
a passed-in value first.

Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
7 months agoGH-130614: pathlib ABCs: revise test suite for writable paths (#131112)
Barney Gale [Wed, 12 Mar 2025 19:06:43 +0000 (19:06 +0000)] 
GH-130614: pathlib ABCs: revise test suite for writable paths (#131112)

Test `pathlib.types._WritablePath` in a dedicated test module. These tests
cover `WritableZipPath`, `WritableLocalPath` and `Path`, where the former
two classes are implementations of `_WritablePath` for use in tests.

7 months agogh-131141: fix data race in instrumentation while registering callback (#131142)
Kumar Aditya [Wed, 12 Mar 2025 18:41:52 +0000 (00:11 +0530)] 
gh-131141: fix data race in instrumentation while registering callback (#131142)

7 months agoImprove docstring for random.binomialvariate (gh-131164)
Raymond Hettinger [Wed, 12 Mar 2025 18:25:31 +0000 (13:25 -0500)] 
Improve docstring for random.binomialvariate (gh-131164)

Add probability distribution to the docstring

7 months agogh-110097: Fix flaky `test_timeout` in `test_concurrent_futures.test_process_pool...
Sam Gross [Wed, 12 Mar 2025 17:16:23 +0000 (13:16 -0400)] 
gh-110097: Fix flaky `test_timeout` in `test_concurrent_futures.test_process_pool` (gh-131108)

On heavily loaded systems, the launch of the workers to run
`time.sleep(0)` can take longer than the five second timeout.

7 months agoGH-127705: Fix _Py_RefcntAdd to handle objects becoming immortal (GH-131140)
Mark Shannon [Wed, 12 Mar 2025 16:54:10 +0000 (16:54 +0000)] 
GH-127705: Fix _Py_RefcntAdd to handle objects becoming immortal (GH-131140)

7 months agogh-111178: Change Argument Clinic signature for `@classmethod` (#131157)
Victor Stinner [Wed, 12 Mar 2025 16:42:07 +0000 (17:42 +0100)] 
gh-111178: Change Argument Clinic signature for `@classmethod` (#131157)

Use "PyObject*", instead of "PyTypeObject*", for `@classmethod`
functions to fix an undefined behavior.

7 months agogh-115999: Add free-threaded specialization for FOR_ITER (#128798)
T. Wouters [Wed, 12 Mar 2025 15:21:46 +0000 (16:21 +0100)] 
gh-115999: Add free-threaded specialization for FOR_ITER (#128798)

Add free-threaded versions of existing specialization for FOR_ITER (list, tuples, fast range iterators and generators), without significantly affecting their thread-safety. (Iterating over shared lists/tuples/ranges should be fine like before. Reusing iterators between threads is not fine, like before. Sharing generators between threads is a recipe for significant crashes, like before.)

7 months agogh-131152: Remove unused imports in `_pyrepl` and `ctypes` (#131150)
Victor Stinner [Wed, 12 Mar 2025 14:04:12 +0000 (15:04 +0100)] 
gh-131152: Remove unused imports in `_pyrepl` and `ctypes` (#131150)

7 months agogh-131152, pkgutil: Remove unused imports (#131149)
Victor Stinner [Wed, 12 Mar 2025 14:03:36 +0000 (15:03 +0100)] 
gh-131152, pkgutil: Remove unused imports (#131149)

7 months agogh-131121: Fix `_Py_atomic_store_char_relaxed` memory order (gh-131122)
Sam Gross [Wed, 12 Mar 2025 13:03:04 +0000 (09:03 -0400)] 
gh-131121: Fix `_Py_atomic_store_char_relaxed` memory order (gh-131122)

7 months agogh-120608: Make reversed iterator work with free-threading (#120971)
Pieter Eendebak [Wed, 12 Mar 2025 11:39:52 +0000 (12:39 +0100)] 
gh-120608: Make reversed iterator work with free-threading (#120971)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
7 months agogh-111178: Fix type of PyCMethod's "nargs" argument (GH-131135)
Victor Stinner [Wed, 12 Mar 2025 10:54:02 +0000 (11:54 +0100)] 
gh-111178: Fix type of PyCMethod's "nargs" argument (GH-131135)

Replace "size_t nargs" with "Py_ssize_t nargs" in PyCMethod.

7 months agogh-129349: Accept bytes in bytes.fromhex()/bytearray.fromhex() (#129844)
Daniel Pope [Wed, 12 Mar 2025 10:40:11 +0000 (10:40 +0000)] 
gh-129349: Accept bytes in bytes.fromhex()/bytearray.fromhex() (#129844)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
7 months agogh-123471: make `itertools.batched` thread-safe (#129416)
Pieter Eendebak [Wed, 12 Mar 2025 10:00:33 +0000 (11:00 +0100)] 
gh-123471: make `itertools.batched` thread-safe (#129416)

7 months agogh-81267: Correct time.sleep() error message (#131055)
Stan Ulbrych [Wed, 12 Mar 2025 08:12:57 +0000 (08:12 +0000)] 
gh-81267: Correct time.sleep() error message (#131055)

7 months agogh-93096: Load doctests in `test_itertools` (#131133)
donBarbos [Wed, 12 Mar 2025 07:40:59 +0000 (11:40 +0400)] 
gh-93096: Load doctests in `test_itertools` (#131133)

7 months agogh-111178: Fix function signatures in rangeobject.c (#131101)
Victor Stinner [Wed, 12 Mar 2025 06:29:20 +0000 (07:29 +0100)] 
gh-111178: Fix function signatures in rangeobject.c (#131101)

7 months agoUse subTest() in math.fma() tests (#131125)
Sergey B Kirpichev [Wed, 12 Mar 2025 06:22:28 +0000 (09:22 +0300)] 
Use subTest() in math.fma() tests (#131125)

7 months agogh-117174: Fix reference leak and gdb tests (#131095)
Pablo Galindo Salgado [Tue, 11 Mar 2025 23:17:58 +0000 (23:17 +0000)] 
gh-117174: Fix reference leak and gdb tests (#131095)

7 months agogh-131113: Fix data race in dict.popitem() (gh-131115)
Sam Gross [Tue, 11 Mar 2025 23:15:22 +0000 (19:15 -0400)] 
gh-131113: Fix data race in dict.popitem() (gh-131115)

The clearing of the key, hash, and value need to use atomic operations
to avoid a data race with concurrent read operations.

7 months agoGH-130614: pathlib ABCs: revise test suite for readable paths (#131018)
Barney Gale [Tue, 11 Mar 2025 20:54:22 +0000 (20:54 +0000)] 
GH-130614: pathlib ABCs: revise test suite for readable paths (#131018)

Test `pathlib.types._ReadablePath` in a dedicated test module. These tests
cover `ReadableZipPath`, `ReadableLocalPath` and `Path`, where the former
two classes are implementations of `_ReadablePath` for use in tests.

7 months agogh-128002: add `test_asyncio.test_free_threading` to tsan tests (#131106)
Kumar Aditya [Tue, 11 Mar 2025 20:03:44 +0000 (01:33 +0530)] 
gh-128002: add `test_asyncio.test_free_threading` to tsan tests (#131106)

7 months agofix various warnings in `test_asyncio.test_tasks` (#131109)
Kumar Aditya [Tue, 11 Mar 2025 19:51:53 +0000 (01:21 +0530)] 
fix various warnings in `test_asyncio.test_tasks` (#131109)

7 months agogh-122029: Do not unpack method for legacy tracing anymore (#130898)
Tian Gao [Tue, 11 Mar 2025 18:04:22 +0000 (14:04 -0400)] 
gh-122029: Do not unpack method for legacy tracing anymore (#130898)

7 months agoGH-130614: pathlib ABCs: revise test suite for Windows path joining (#131016)
Barney Gale [Tue, 11 Mar 2025 18:01:43 +0000 (18:01 +0000)] 
GH-130614: pathlib ABCs: revise test suite for Windows path joining (#131016)

Test Windows-flavoured `pathlib.types._JoinablePath` in a dedicated test
module. These tests cover `LexicalWindowsPath`, `PureWindowsPath` and
`WindowsPath`, where `LexicalWindowsPath` is a simple implementation of
`_JoinablePath` for use in tests.

7 months agoReplace link to historical TypedDict PEP with current document on typing.python…...
Gerardwx [Tue, 11 Mar 2025 16:45:31 +0000 (12:45 -0400)] 
Replace link to historical TypedDict PEP with current document on typing.python… (#131096)

* Replace link to historical PEP with current document on typing.python.org

* Update Doc/library/typing.rst

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
---------

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
7 months agogh-111178: Change Argument Clinic signature for METH_O (#130682)
Victor Stinner [Tue, 11 Mar 2025 15:33:36 +0000 (16:33 +0100)] 
gh-111178: Change Argument Clinic signature for METH_O (#130682)

Use "PyObject*" for METH_O functions to fix an undefined behavior.

7 months agogh-130396: Fix thread sanitizer crashes on stack overflow tests (gh-130966)
Sam Gross [Tue, 11 Mar 2025 14:33:23 +0000 (10:33 -0400)] 
gh-130396: Fix thread sanitizer crashes on stack overflow tests (gh-130966)

Thread sanitizer will often crash if a test uses more than half the
stack.

7 months agogh-130957: Use `sleeping_retry` in `test_free_reference` (#130958)
Sam Gross [Tue, 11 Mar 2025 13:51:26 +0000 (09:51 -0400)] 
gh-130957: Use `sleeping_retry` in `test_free_reference` (#130958)

The weak reference may not be immediately dead.

7 months agoReplace K&R function declarations with ANSI declarations (#114818)
Max Bachmann [Tue, 11 Mar 2025 12:06:36 +0000 (13:06 +0100)] 
Replace K&R function declarations with ANSI declarations (#114818)

7 months agoGH-127705: Check for immortality in refcount accounting (#131072)
Mark Shannon [Tue, 11 Mar 2025 11:53:07 +0000 (11:53 +0000)] 
GH-127705: Check for immortality in refcount accounting (#131072)

Check for immortality in refcount accounting

7 months agogh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (#131044)
Max Bachmann [Tue, 11 Mar 2025 11:33:01 +0000 (12:33 +0100)] 
gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (#131044)

* Add missing guards for WIN32_LEAN_AND_MEAN

* add missing whitespaces

7 months agogh-93096: Remove `-t` and `-v` flags from `pickle` cli (#131068)
donBarbos [Tue, 11 Mar 2025 11:07:00 +0000 (15:07 +0400)] 
gh-93096: Remove `-t` and `-v` flags from `pickle` cli (#131068)

* Remove `python -m pickle -t`

* Revert adding doctest to unittests

7 months agogh-93096: Remove `-t` and `-v` flags from `pickletools` cli (#131039)
donBarbos [Tue, 11 Mar 2025 11:06:26 +0000 (15:06 +0400)] 
gh-93096: Remove `-t` and `-v` flags from `pickletools` cli (#131039)

Remove `python -m pickletools -t`

7 months agogh-93096: Load doctests in `test_pickle` (#131069)
donBarbos [Tue, 11 Mar 2025 10:25:25 +0000 (14:25 +0400)] 
gh-93096: Load doctests in `test_pickle` (#131069)

Add doctests to unittest for `pickle`

7 months agogh-129675: Update documentation for tp_basicsize & tp_itemsize (#129850)
Petr Viktorin [Tue, 11 Mar 2025 10:21:18 +0000 (11:21 +0100)] 
gh-129675: Update documentation for tp_basicsize & tp_itemsize (#129850)

* Update documentation for tp_basicsize & tp_itemsize

- Add alignment requirement
- Mention that ob_size is unreliable if you don't control it
- Add some links for context
- basicsize should include the base type in generaly not just PyObject

This adds a “by-the-way” link to `PyObject_New`, which shouldn't be
used for GC types. In order to be comfortable linking to it, I also
add a link to `PyObject_GC_New` from its docs. And the same for
`*Var` variants, while I'm here.

* Strongly suggest Py_SIZE & Py_SET_SIZE

7 months agogh-46236: Add missing PyUnicode_Append() doc (#130531)
RUANG (James Roy) [Tue, 11 Mar 2025 09:28:17 +0000 (17:28 +0800)] 
gh-46236: Add missing PyUnicode_Append() doc (#130531)

* Add missing PyUnicode_Append() doc

* Change the copied content

* Add '`` ``'

* Change doc

* Add PyUnicode_AppendAndDel function doc

* Change doc

* Add PyUnicode_AppendAndDel to refcounts

* Change doc

* Change doc

Co-authored-by: Petr Viktorin <encukou@gmail.com>
* Change doc

---------

Co-authored-by: Petr Viktorin <encukou@gmail.com>
7 months agogh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()` (#130962)
Michał Górny [Tue, 11 Mar 2025 09:15:40 +0000 (10:15 +0100)] 
gh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()` (#130962)

* gh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()`

Fix the pure Python implementation of `fromisoformat()` to reject any
non-digit characters, including whitespace, in the fractional part
of time specification.  This makes the behavior consistent with the C
implementation, and prevents incorrect parsing of these fractions
(e.g. `.400 ` would be misinterpreted as `.04`).

* Add the news entry

* Use a different example to fix Sphinx lint

* Apply suggestions from code review

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
* Try fixing `:func:` ref.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
7 months agogh-130932: cwd cannot be removed on Solaris/Illumos (#131037)
Jakub Kulík [Tue, 11 Mar 2025 09:09:04 +0000 (10:09 +0100)] 
gh-130932: cwd cannot be removed on Solaris/Illumos (#131037)

7 months agoMinor nits to whats new tail call wording (#130912)
Ken Jin [Tue, 11 Mar 2025 02:57:35 +0000 (10:57 +0800)] 
Minor nits to whats new tail call wording (#130912)

7 months agogh-130039: Tailcall for windows builds (GH-130040)
Ken Jin [Tue, 11 Mar 2025 02:52:56 +0000 (10:52 +0800)] 
gh-130039: Tailcall for windows builds (GH-130040)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
7 months agogh-117174: Adapt test_multiple_statements_fail_early now that we have always source...
Pablo Galindo Salgado [Mon, 10 Mar 2025 23:10:53 +0000 (23:10 +0000)] 
gh-117174: Adapt test_multiple_statements_fail_early now that we have always source (#131065)

7 months agogh-130804: Fix support of typing unicode chars in pyrepl (#130805)
Sergey Miryanov [Mon, 10 Mar 2025 22:13:50 +0000 (03:13 +0500)] 
gh-130804: Fix support of typing unicode chars in pyrepl (#130805)

7 months agogh-124927: Fix conversion issue between coordinates and position in REPL (#125001)
FeH2 [Mon, 10 Mar 2025 21:54:49 +0000 (05:54 +0800)] 
gh-124927: Fix conversion issue between coordinates and position in REPL (#125001)

7 months agogh-117174: Add a new route in linecache to fetch interactive source code (#117500)
Pablo Galindo Salgado [Mon, 10 Mar 2025 21:54:05 +0000 (21:54 +0000)] 
gh-117174: Add a new route in linecache to fetch interactive source code (#117500)

7 months agogh-118518: Minor improvements to perf docs (#130866)
stratakis [Mon, 10 Mar 2025 21:51:21 +0000 (22:51 +0100)] 
gh-118518: Minor improvements to perf docs (#130866)

Minor improvements to perf docs

7 months agogh-128515: Properly check for bolt in test_perf_profiler (#131058)
Pablo Galindo Salgado [Mon, 10 Mar 2025 21:48:03 +0000 (21:48 +0000)] 
gh-128515: Properly check for bolt in test_perf_profiler (#131058)

7 months agoAdd Ammar to CODEOWNERS for fuzzing (#131057)
Ammar Askar [Mon, 10 Mar 2025 20:58:36 +0000 (13:58 -0700)] 
Add Ammar to CODEOWNERS for fuzzing (#131057)

7 months agogh-131020: py.exe launcher does not correctly detect a BOM when searching for the...
Chris Eibl [Mon, 10 Mar 2025 17:59:23 +0000 (18:59 +0100)] 
gh-131020: py.exe launcher does not correctly detect a BOM when searching for the shebang (GH-131021)

7 months agoGH-130614: pathlib ABCs: revise test suite for Posix path joining (#131017)
Barney Gale [Mon, 10 Mar 2025 17:59:10 +0000 (17:59 +0000)] 
GH-130614: pathlib ABCs: revise test suite for Posix path joining (#131017)

Test Posix-flavoured `pathlib.types._JoinablePath` in a dedicated test
module. These tests cover `LexicalPosixPath`, `PurePosixPath` and
`PosixPath`, where `LexicalPosixPath` is a simple implementation of
`_JoinablePath` for use in tests.

7 months agoGH-127381: pathlib ABCs: remove `case_sensitive` argument (#131024)
Barney Gale [Mon, 10 Mar 2025 17:50:48 +0000 (17:50 +0000)] 
GH-127381: pathlib ABCs: remove `case_sensitive` argument (#131024)

Remove the *case_sensitive* argument from `_JoinablePath.full_match()` and
`_ReadablePath.glob()`. Using a non-native case sensitivity forces the use
of "case-pedantic" globbing, where we `iterdir()` even for non-wildcard
pattern segments. But it's hard to know when to enable this mode, as
case-sensitivity can vary by directory, so `_PathParser.normcase()` doesn't
always give the full picture. The `Path.glob()` implementation is forced to
make an educated guess, but we can avoid the issue in the ABCs by dropping
the *case_sensitive* argument.

(I probably shouldn't have added these arguments in `PurePath` and `Path`
in the first place!)

Also drop support for `_ReadablePath.glob(recurse_symlinks=False)`, which
makes recursive globbing much slower.

7 months agogh-82909: Update PC/pyconfig.h to allow disabling pragma based auto-linking (GH-19740)
Jean-Christophe Fillion-Robin [Mon, 10 Mar 2025 17:40:17 +0000 (00:40 +0700)] 
gh-82909: Update PC/pyconfig.h to allow disabling pragma based auto-linking (GH-19740)

Define Py_NO_LINK_LIB to build extension disabling pragma based auto-linking. This is relevant when using build-system generator (e.g CMake) where the linking is explicitly handled

7 months agoGH-123044: Give the `POP_TOP` after a case test a location in the body, not the patte...
Mark Shannon [Mon, 10 Mar 2025 17:31:16 +0000 (17:31 +0000)] 
GH-123044: Give the `POP_TOP` after a case test a location in the body, not the pattern. (GH-130627)

7 months agoGH-131035: Use -flto=thin for clang-cl on Windows (GH-131036)
Chris Eibl [Mon, 10 Mar 2025 16:47:45 +0000 (17:47 +0100)] 
GH-131035: Use -flto=thin for clang-cl on Windows (GH-131036)

7 months agoGH-127705: Use `_PyStackRef`s in the default build. (GH-127875)
Mark Shannon [Mon, 10 Mar 2025 14:06:56 +0000 (14:06 +0000)] 
GH-127705: Use `_PyStackRef`s in the default build. (GH-127875)

8 months agogh-101100: Fix sphinx warnings in `library/asyncio-subprocess.rst` (#130994)
Yuki Kobayashi [Mon, 10 Mar 2025 12:38:08 +0000 (21:38 +0900)] 
gh-101100: Fix sphinx warnings in `library/asyncio-subprocess.rst` (#130994)

8 months agogh-80421: Correct definitions of time (#130984)
Stan Ulbrych [Sun, 9 Mar 2025 20:09:23 +0000 (20:09 +0000)] 
gh-80421: Correct definitions of time (#130984)

Based on the Wikipedia article, UTC is better said to be a successor than a renaming of GTC and language agnostic rather than an English-French compromise.

8 months agoGH-130614: pathlib ABCs: revise test suite for path joining (#130988)
Barney Gale [Sun, 9 Mar 2025 17:02:37 +0000 (17:02 +0000)] 
GH-130614: pathlib ABCs: revise test suite for path joining (#130988)

Test `pathlib.types._JoinablePath` in a dedicated test module. These tests
cover `LexicalPath`, `PurePath` and `Path`, where `LexicalPath` is defined
in a new `test.test_pathlib.support` package.

8 months agoGH-130614: pathlib ABCs: support alternate separator in `full_match()` (#130991)
Barney Gale [Sun, 9 Mar 2025 16:36:59 +0000 (16:36 +0000)] 
GH-130614: pathlib ABCs: support alternate separator in `full_match()` (#130991)

In `pathlib.types._JoinablePath.full_match()`, treat alternate path
separators in the path and pattern as if they were primary separators. e.g.
if the parser is `ntpath`, then `P(r'foo/bar\baz').full_match(r'*\*/*')` is
true.

8 months agoGH-130614: pathlib ABCs: retain original separator in `with_name()` (#130990)
Barney Gale [Sun, 9 Mar 2025 16:36:20 +0000 (16:36 +0000)] 
GH-130614: pathlib ABCs: retain original separator in `with_name()` (#130990)

In `pathlib.types._JoinablePath.with_name()`, retain any alternative path
separator preceding the old name, rather stripping and replacing it with a
primary separator. As a result, this method changes _only_ the name.

8 months agogh-130160: use `.. program::` directive for documenting `pdb` CLI (#130996)
donBarbos [Sun, 9 Mar 2025 15:55:23 +0000 (19:55 +0400)] 
gh-130160: use `.. program::` directive for documenting `pdb` CLI (#130996)

8 months agogh-130160: use `.. program::` directive for documenting `webbrowser` CLI (#130995)
donBarbos [Sun, 9 Mar 2025 06:57:59 +0000 (10:57 +0400)] 
gh-130160: use `.. program::` directive for documenting `webbrowser` CLI (#130995)

use `.. program::` directive for documenting `webbrowser` CLI

8 months agogh-123726: Document caveats of zipfile.Path around name sanitization (#130537)
Affan Shaikhsurab [Sat, 8 Mar 2025 21:37:05 +0000 (03:07 +0530)] 
gh-123726: Document caveats of zipfile.Path around name sanitization (#130537)

Add a note to the `zipfile.Path` class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references the `extract` and `extractall` methods for comparison and suggests using `os.path.abspath` and `os.path.commonpath` for safe filename resolution.

8 months agogh-130954: Fix multiprocessing test_notify_n (#130955)
Sam Gross [Sat, 8 Mar 2025 18:04:30 +0000 (13:04 -0500)] 
gh-130954: Fix multiprocessing test_notify_n (#130955)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This takes two approaches to fix this:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Clarify wording in Whats new for Tail call

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

This amends f39a07be47

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

Typo introduced in gh-118910.

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

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

* Add correction note to tail call in whats new

* Update 3.14.rst

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

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

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

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

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

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

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

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