]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
8 months agogh-128317: Move CLI calendar highlighting to private class (#129625)
Hugo van Kemenade [Sat, 8 Feb 2025 15:56:57 +0000 (17:56 +0200)] 
gh-128317: Move CLI calendar highlighting to private class (#129625)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
8 months agogh-129173: Use `_PyUnicodeError_GetParams` in `PyCodec_NameReplaceErrors` (GH-129135)
Bénédikt Tran [Sat, 8 Feb 2025 15:01:57 +0000 (16:01 +0100)] 
gh-129173: Use `_PyUnicodeError_GetParams` in `PyCodec_NameReplaceErrors` (GH-129135)

8 months agogh-115806: Don't mangle gdbm header dependency detection output (#129390)
Erlend E. Aasland [Sat, 8 Feb 2025 14:38:11 +0000 (15:38 +0100)] 
gh-115806: Don't mangle gdbm header dependency detection output (#129390)

Replace AC_CACHE_VAL/AC_CHECK_HEADER with a cleaner variant using
AC_CACHE_CHECK/AC_PREPROC_IFELSE.

The former would produce garbled output when config.cache was reused. It
also required directly manipulating GNU Autoconf cache variables.

8 months agogh-111178: fix UBSan failures in `Objects/frameobject.c` (GH-129777)
Bénédikt Tran [Sat, 8 Feb 2025 13:54:34 +0000 (14:54 +0100)] 
gh-111178: fix UBSan failures in `Objects/frameobject.c` (GH-129777)

fix UBSan failures for `PyFrameObject`, `PyFrameLocalsProxyObject`

8 months agogh-111178: fix UBSan failures in `Objects/floatobject.c` (GH-129776)
Bénédikt Tran [Sat, 8 Feb 2025 13:47:19 +0000 (14:47 +0100)] 
gh-111178: fix UBSan failures in `Objects/floatobject.c` (GH-129776)

fix UBSan failures for `PyFloatObject`

8 months agogh-111178: fix UBSan failures in `Modules/arraymodule.c` (GH-129772)
Bénédikt Tran [Sat, 8 Feb 2025 13:26:14 +0000 (14:26 +0100)] 
gh-111178: fix UBSan failures in `Modules/arraymodule.c` (GH-129772)

* fix UBSan failures for `arrayobject`, `arrayiterobject`
* suppress unused return values

8 months agogh-111178: fix UBSan failures in `Modules/_io/*.c` (GH-129083)
Bénédikt Tran [Sat, 8 Feb 2025 13:21:32 +0000 (14:21 +0100)] 
gh-111178: fix UBSan failures in `Modules/_io/*.c` (GH-129083)

* fix UBSan failures for `buffered`, `rwpair`, `bytesio`, `bytesiobuf`, `iobase`, `stringio`, `nldecoder_object`, `textio`, `winconsoleio`

* arg names: use 'dummy' for NOARGS method and 'args' for others

8 months agogh-119349: Add ctypes.util.dllist -- list loaded shared libraries (GH-122946)
Brian Ward [Sat, 8 Feb 2025 13:02:36 +0000 (08:02 -0500)] 
gh-119349: Add ctypes.util.dllist -- list loaded shared libraries (GH-122946)

Add function to list the currently loaded libraries to ctypes.util

The dllist() function calls platform-specific APIs in order to
list the runtime libraries loaded by Python and any imported modules.
On unsupported platforms the function may be missing.

Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
8 months agogh-129842: warnings.py: Remove obsolete requirement reference (GH-129845)
Stan Ulbrych [Sat, 8 Feb 2025 12:57:17 +0000 (12:57 +0000)] 
gh-129842: warnings.py: Remove obsolete requirement reference (GH-129845)

8 months agoUse ubuntu-22.04-arm image for Arm runners. (#129834)
Diego Russo [Sat, 8 Feb 2025 06:56:19 +0000 (06:56 +0000)] 
Use ubuntu-22.04-arm image for Arm runners. (#129834)

GitHub suggested us to try the 22.04 images for the Arm runners while
they are invetigating the failures we've been having using 24.04.

8 months agoGH-129835: Yield path with trailing slash from `ReadablePath.glob('')` (#129836)
Barney Gale [Sat, 8 Feb 2025 06:47:09 +0000 (06:47 +0000)] 
GH-129835: Yield path with trailing slash from `ReadablePath.glob('')` (#129836)

In the private pathlib ABCs, make `ReadablePath.glob('')` yield a path with
a trailing slash (if it yields anything at all). As a result, `glob()`
works similarly to `joinpath()` when given a non-magic pattern.

In the globbing implementation, we preemptively add trailing slashes to
intermediate paths if there are pattern parts remaining; this removes the
need to check for existing trailing slashes (in the removed `add_slash()`
method) at subsequent steps.

8 months agogh-128657: fix _hashopenssl ref/data race (GH-128886)
Tomasz Pytel [Sat, 8 Feb 2025 02:47:45 +0000 (21:47 -0500)] 
gh-128657: fix _hashopenssl ref/data race (GH-128886)

8 months agogh-124703: Add documentation and whatsnew entry for pdb exit change (#129818)
Tian Gao [Sat, 8 Feb 2025 02:02:46 +0000 (21:02 -0500)] 
gh-124703: Add documentation and whatsnew entry for pdb exit change (#129818)

8 months agoGH-125413: Add `pathlib.Path.info` attribute (#127730)
Barney Gale [Sat, 8 Feb 2025 01:16:45 +0000 (01:16 +0000)] 
GH-125413: Add `pathlib.Path.info` attribute (#127730)

Add `pathlib.Path.info` attribute, which stores an object implementing the `pathlib.types.PathInfo` protocol (also new). The object supports querying the file type and internally caching `os.stat()` results. Path objects generated by `Path.iterdir()` are initialised with status information from `os.DirEntry` objects, which is gleaned from scanning the parent directory.

The `PathInfo` protocol has four methods: `exists()`, `is_dir()`, `is_file()` and `is_symlink()`.

8 months agogh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR (#129700)
Irit Katriel [Fri, 7 Feb 2025 22:39:54 +0000 (22:39 +0000)] 
gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR (#129700)

8 months agogh-129825: Skip test_faulthandler.test_register_chain under TSAN (gh-129827)
Sam Gross [Fri, 7 Feb 2025 22:35:59 +0000 (17:35 -0500)] 
gh-129825: Skip test_faulthandler.test_register_chain under TSAN (gh-129827)

The test hangs when run under TSAN due to an interaction between TSAN's
signal interception and our attempt to call the previous signal handler.

8 months agoGH-129715: Remove _DYNAMIC_EXIT (GH-129716)
Brandt Bucher [Fri, 7 Feb 2025 19:41:17 +0000 (11:41 -0800)] 
GH-129715: Remove _DYNAMIC_EXIT (GH-129716)

8 months agoFix link in 3.14 whatsnew (#129828)
Ken Jin [Fri, 7 Feb 2025 19:30:23 +0000 (03:30 +0800)] 
Fix link in 3.14 whatsnew (#129828)

8 months agoRemove tail-calling wording as it is confusing (GH-129823)
Ken Jin [Fri, 7 Feb 2025 18:49:28 +0000 (02:49 +0800)] 
Remove tail-calling wording as it is confusing (GH-129823)

8 months agoimprove `test_log_destroyed_pending_task` in asyncio (#129821)
Kumar Aditya [Fri, 7 Feb 2025 18:00:59 +0000 (23:30 +0530)] 
improve `test_log_destroyed_pending_task` in asyncio (#129821)

8 months agoFix Garrett Gu name misspelling in 3.14 whatsnew (GH-129822)
Garrett Gu [Fri, 7 Feb 2025 17:56:46 +0000 (11:56 -0600)] 
Fix Garrett Gu name misspelling in 3.14 whatsnew (GH-129822)

Update 3.14.rst to fix typo

8 months agoGH-129709: Clean up tier two (GH-129710)
Brandt Bucher [Fri, 7 Feb 2025 17:52:49 +0000 (09:52 -0800)] 
GH-129709: Clean up tier two (GH-129710)

8 months agoGH-129763: Remove the LLTRACE macro (GH-129764)
Brandt Bucher [Fri, 7 Feb 2025 16:49:51 +0000 (08:49 -0800)] 
GH-129763: Remove the LLTRACE macro (GH-129764)

8 months agofix tests in `test_asyncio.test_tasks` to use correct `all_tasks` (#129815)
Kumar Aditya [Fri, 7 Feb 2025 16:16:26 +0000 (21:46 +0530)] 
fix tests in `test_asyncio.test_tasks` to use correct `all_tasks` (#129815)

9 months agogh-128563: Clarify clarificatory tail calling wording in What's New (#129812)
Adam Turner [Fri, 7 Feb 2025 15:12:33 +0000 (15:12 +0000)] 
gh-128563: Clarify clarificatory tail calling wording in What's New (#129812)

9 months agogh-128563: Clarify tail calling interpreter is not TCO (#129809)
Ken Jin [Fri, 7 Feb 2025 14:59:34 +0000 (22:59 +0800)] 
gh-128563: Clarify tail calling interpreter is not TCO (#129809)

Clarify tail calling interpreter is not TCO

9 months agogh-117657: Fix data race in `dict_dict_merge` (gh-129755)
Sam Gross [Fri, 7 Feb 2025 14:44:24 +0000 (09:44 -0500)] 
gh-117657: Fix data race in `dict_dict_merge` (gh-129755)

Found while running `test_load_attr_module` from `test_opcache` under TSan.

9 months agogh-128563: Move assignment of opcode into ifdef (GH-129803)
Ken Jin [Fri, 7 Feb 2025 13:11:57 +0000 (21:11 +0800)] 
gh-128563: Move assignment of opcode into ifdef (GH-129803)

9 months agogh-128563: Document the tail-calling interpreter (GH-129728)
Ken Jin [Fri, 7 Feb 2025 12:18:15 +0000 (20:18 +0800)] 
gh-128563: Document the tail-calling interpreter (GH-129728)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
9 months agogh-129005: Align FileIO.readall between _pyio and _io (#129705)
Cody Maloney [Fri, 7 Feb 2025 11:06:11 +0000 (03:06 -0800)] 
gh-129005: Align FileIO.readall between _pyio and _io (#129705)

Utilize `bytearray.resize()` and `os.readinto()` to reduce copies
and match behavior of `_io.FileIO.readall()`.

There is still an extra copy which means twice the memory required
compared to FileIO because there isn't a zero-copy  path from
`bytearray` -> `bytes` currently.

On my system reading a 2 GB file:
`./python -m test -M8g -uall test_largefile -m test.test_largefile.PyLargeFileTest.test_large_read -v`

Goes from ~2.7 seconds -> ~2.2 seconds

Co-authored-by: Victor Stinner <vstinner@python.org>
9 months agogh-129766: Fix crash on calling `warnings._release_lock` with no lock (#129771)
sobolevn [Fri, 7 Feb 2025 09:59:52 +0000 (12:59 +0300)] 
gh-129766: Fix crash on calling `warnings._release_lock` with no lock (#129771)

9 months agoEmscripten: use better `_Py_Version` computation for worker module (#129757)
Agriya Khetarpal [Fri, 7 Feb 2025 04:55:27 +0000 (04:55 +0000)] 
Emscripten: use better `_Py_Version` computation for worker module (#129757)

Use integer bit shifting instead of conversion to strings to compute Python version.

9 months agogh-55454: Add IMAP4 IDLE support to imaplib (#122542)
Forest [Fri, 7 Feb 2025 03:15:11 +0000 (03:15 +0000)] 
gh-55454: Add IMAP4 IDLE support to imaplib (#122542)

* gh-55454: Add IMAP4 IDLE support to imaplib

This extends imaplib with support for the rfc2177 IMAP IDLE command,
as requested in #55454.  It allows events to be pushed to a client as
they occur, rather than having to continually poll for mailbox changes.

The interface is a new idle() method, which returns an iterable context
manager.  Entering the context starts IDLE mode, during which events
(untagged responses) can be retrieved using the iteration protocol.
Exiting the context sends DONE to the server, ending IDLE mode.

An optional time limit for the IDLE session is supported, for use with
servers that impose an inactivity timeout.

The context manager also offers a burst() method, designed for programs
wishing to process events in batch rather than one at a time.

Notable differences from other implementations:

- It's an extension to imaplib, rather than a replacement.
- It doesn't introduce additional threads.
- It doesn't impose new requirements on the use of imaplib's existing methods.
- It passes the unit tests in CPython's test/test_imaplib.py module
  (and adds new ones).
- It works on Windows, Linux, and other unix-like systems.
- It makes IDLE available on all of imaplib's client variants
  (including IMAP4_stream).
- The interface is pythonic and easy to use.

Caveats:

- Due to a Windows limitation, the special case of IMAP4_stream running
  on Windows lacks a duration/timeout feature. (This is the stdin/stdout
  pipe connection variant; timeouts work fine for socket-based
  connections, even on Windows.) I have documented it where appropriate.

- The file-like imaplib instance attributes are changed from buffered to
  unbuffered mode. This could potentially break any client code that
  uses those objects directly without expecting partial reads/writes.
  However, these attributes are undocumented. As such, I think (and
  PEP 8 confirms) that they are fair game for changes.
  https://peps.python.org/pep-0008/#public-and-internal-interfaces

Usage examples:

https://github.com/python/cpython/issues/55454#issuecomment-2227543041

Original discussion:

https://discuss.python.org/t/gauging-interest-in-my-imap4-idle-implementation-for-imaplib/59272

Earlier requests and suggestions:

https://github.com/python/cpython/issues/55454

https://mail.python.org/archives/list/python-ideas@python.org/thread/C4TVEYL5IBESQQPPS5GBR7WFBXCLQMZ2/

* gh-55454: Clarify imaplib idle() docs

- Add example idle response tuples, to make the minor difference from other
  imaplib response tuples more obvious.
- Merge the idle context manager's burst() method docs with the IMAP
  object's idle() method docs, for easier understanding.
- Upgrade the Windows note regarding lack of pipe timeouts to a warning.
- Rephrase various things for clarity.

* docs: words instead of <=

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* docs: improve style in an example

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* docs: grammatical edit

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* docs consistency

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* comment -> docstring

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* docs: refer to imaplib as "this module"

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* imaplib: simplify & clarify idle debug message

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* imaplib: elaborate in idle context manager comment

* imaplib: re-raise BaseException instead of bare except

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* imaplib: convert private doc string to comment

* docs: correct mistake in imaplib example

This is a correction to 8077f2eab287703b77350f1bfc9db2bd236dd9a7, which
changed a variable name in only one place and broke the subsequent
reference to it, departed from the naming convention used in the rest of
the module, and shadowed the type() builtin along the way.

* imaplib: simplify example code in doc string

This is for consistency with the documentation change in 8077f2eab287
and subsequent correction in 013bbf18fc42.

* imaplib: rename _Idler to Idler, update its docs

* imaplib: add comment in Idler._pop()

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* imaplib: remove unnecessary blank line

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* imaplib: comment on use of unbuffered pipes

* docs: imaplib: use the reStructuredText :class: role

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* Revert "docs: imaplib: use the reStructuredText :class: role"

This reverts commit f385e441df15d962d1f22e9bab2f15a39e5363d5, because it
triggers CI failures in the docs by referencing a class that is
(deliberately) undocumented.

* docs: imaplib: use the reST :class: role, escaped

This is a different approach to f385e441df15, which was reverted for
creating dangling link references.

By prefixing the reStructuredText role target with a ! we disable
conversion to a link, thereby passing continuous integration checks
even though the referenced class is deliberately absent from the
documentation.

* docs: refer to IMAP4 IDLE instead of just IDLE

This clarifies that we are referring to the email protocol, not the editor with the same name.

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* imaplib: IDLE -> IMAP4 IDLE in exception message

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* docs: imaplib idle() phrasing and linking tweaks

* docs: imaplib: avoid linking to an invalid target

This reverts and rephrases part of a3f21cd75b4d7c97c0d7e46b0a0cc0875e29f6cc
which created links to a method on a deliberately undocumented class.
The links didn't work consistently, and caused sphinx warnings that
broke cpython's continuous integration tests.

* imaplib: update test after recent exception change

This fixes a test that was broken by changing an exception in
b01de95171d6124f8acc7b907c1842472ea5f5fb

* imaplib: rename idle() dur argument to duration

* imaplib: bytes.index() -> bytes.find()

This makes it more obvious which statement triggers the branch.

* imaplib: remove no-longer-necessary statement

Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
* docs: imaplib: concise & valid method links

The burst() method is a little tricky to link in restructuredText, due
to quirks of its parent class.  This syntax allows sphinx to generate
working links without generating warnings (which break continuous
integration) and without burdening the reader with unimportant namespace
qualifications.  It makes the reST source ugly, but few people read
the reST source, so it's a tolerable tradeoff.

* imaplib: note data types present in IDLE responses

* docs: imaplib: add comma to reST changes header

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* imaplib: sync doc strings with reST docs

* docs: imaplib: minor Idler clarifications

* imaplib: idle: emit (type, [data, ...]) tuples

This allows our iterator to emit untagged responses that contain literal
strings in the same way that imaplib's existing methods do, while still
emitting exactly one whole response per iteration.

* imaplib: while/yield instead of yield from iter()

* imaplib: idle: use deadline idiom when iterating

This simplifies the code, and avoids idle duration drift from time spent
processing each iteration.

* docs: imaplib: state duration/interval arg types

* docs: imaplib: minor rephrasing of a sentence

* docs: imaplib: reposition a paragraph

This might improve readability, especially when encountering Idler.burst()
for the first time.

* docs: imaplib: wrap long lines in idle() section

* docs: imaplib: note: Idler objects require 'with'

* docs: imaplib: say that 29 minutes is 1740 seconds

* docs: imaplib: mark a paragraph as a 'tip'

* docs: imaplib: rephrase reference to MS Windows

* imaplib: end doc string titles with a period

* imaplib: idle: socket timeouts instead of select()

IDLE timeouts were originally implemented using select() after
checking for the presence of already-buffered data.
That allowed timeouts on pipe connetions like IMAP4_stream.
However, it seemed possible that SSL data arriving without any
IMAP data afterward could cause select() to indicate available
application data when there was none, leading to a read() call
that would block with no timeout. It was unclear under what
conditions this would happen in practice. This change switches
to socket timeouts instead of select(), just to be safe.

This also reverts IMAP4_stream changes that were made to support IDLE
timeouts, since our new implementation only supports socket connections.

* imaplib: Idler: rename private state attributes

* imaplib: rephrase a comment in example code

* docs: imaplib: idle: use Sphinx code-block:: pycon

* docs: whatsnew: imaplib: reformat IMAP4.idle entry

* imaplib: idle: make doc strings brief

Since we generally rely on the reST/html documentation for details, we
can keep these doc strings short. This matches the module's existing doc
string style and avoids having to sync small changes between two files.

* imaplib: Idler: split assert into two statements

* imaplib: Idler: move assignment out of try: block

* imaplib: Idler: move __exit__() for readability

* imaplib: Idler: move __next__() for readability

* imaplib: test: make IdleCmdHandler a global class

* docs: imaplib: idle: collapse double-spaces

* imaplib: warn on use of undocumented 'file' attr

* imaplib: revert import reformatting

Since we no longer import platform or selectors, the original import
statement style can be restored, reducing the footprint of PR #122542.

* imaplib: restore original exception msg formatting

This reduces the footprint of PR #122542.

* docs: imaplib: idle: versionadded:: next

* imaplib: move import statement to where it's used

This import is only needed if external code tries to use an attribute
that it shouldn't be using. Making it a local import reduces module
loading time in supported cases.

* imaplib test: RuntimeWarning on IMAP4.file access

* imaplib: use stacklevel=2 in warnings.warn()

* imaplib test: simplify IMAP4.file warning test

* imaplib test: pre-idle-continuation response

* imaplib test: post-done untagged response

* imaplib: downgrade idle-denied exception to error

This makes it easier for client code to distinguish a temporary
rejection of the IDLE command from a server responding incorrectly to
IDLE.

* imaplib: simplify check for socket object

* imaplib: narrow the scope of IDLE socket timeouts

If an IDLE duration or burst() was in use, and an unsolicited response
contained a literal string, and crossed a packet boundary, and the
subsequent packet was delayed beyond the IDLE feature's time limit, the
timeout would leave the incoming protocol stream in a bad state (with
the tail of that response appearing where the start of a response is
expected).

This change moves the IDLE socket timeout to cover only the start
of a response, so it can no longer cause that problem.

* imaplib: preserve partial reads on exception

This ensures that short IDLE durations / burst() intervals
won't risk corrupting response lines that span multiple packets.

* imaplib: read/readline: save multipart buffer tail

For resilience if read() or readline() ever complete with more than one
bytes object remaining in the buffer. This is not expected to happen,
but it seems wise to be prepared for a future change making it possible.

* imaplib: use TimeoutError subclass only if needed

* doc: imaplib: elaborate on IDLE response delivery

* doc: imaplib: elaborate in note re: IMAP4.response

* imaplib: comment on benefit of reading in chunks

Our read() implementation designed to support IDLE replaces the one from
PR #119514, fixing the same problem it was addressing. The tests that it
added are preserved.

* imaplib: readline(): treat ConnectionError as EOF

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
9 months agogh-129737: Fix help message for tail calling interpreter configuration (GH-129754)
Pieter Eendebak [Fri, 7 Feb 2025 00:47:13 +0000 (01:47 +0100)] 
gh-129737: Fix help message for tail calling interpreter configuration (GH-129754)

9 months agoAdd multinomial to the itertools recipes docs (gh-129760)
Raymond Hettinger [Fri, 7 Feb 2025 00:35:55 +0000 (18:35 -0600)] 
Add multinomial to the itertools recipes docs (gh-129760)

9 months agogh-117657: Include all of test_free_threading in TSAN tests (#129749)
Sam Gross [Thu, 6 Feb 2025 23:37:05 +0000 (18:37 -0500)] 
gh-117657: Include all of test_free_threading in TSAN tests (#129749)

9 months ago gh-129533: Update PyGC_Enable/Disable/IsEnabled to use atomic operation (gh-129563)
Donghee Na [Thu, 6 Feb 2025 22:41:13 +0000 (07:41 +0900)] 
 gh-129533: Update PyGC_Enable/Disable/IsEnabled to use atomic operation  (gh-129563)

9 months agogh-117657: Skip tests that may cause stack overflows under TSan (#129751)
Sam Gross [Thu, 6 Feb 2025 22:03:01 +0000 (17:03 -0500)] 
gh-117657: Skip tests that may cause stack overflows under TSan (#129751)

These tests crash under TSan due to stack overflows. Just skip them if
TSan is enabled.

9 months agogh-117657: Fix data race in `new_reference` for free threaded build (gh-129665)
Bogdan Romanyuk [Thu, 6 Feb 2025 20:35:37 +0000 (23:35 +0300)] 
gh-117657: Fix data race in `new_reference` for free threaded build (gh-129665)

9 months agogh-128002: use per threads tasks linked list in asyncio (#128869)
Kumar Aditya [Thu, 6 Feb 2025 18:51:07 +0000 (00:21 +0530)] 
gh-128002: use per threads tasks linked list in asyncio (#128869)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
9 months agogh-129732: Fix race on `shared->array` in qsbr code under free-threading (gh-129738)
Peter Hawkins [Thu, 6 Feb 2025 18:49:29 +0000 (13:49 -0500)] 
gh-129732: Fix race on `shared->array` in qsbr code under free-threading (gh-129738)

The read of `shared->array` should happen under the lock to avoid a race.

9 months agogh-112020: Rework socketserver examples to be correct (#129741)
Gregory P. Smith [Thu, 6 Feb 2025 17:42:47 +0000 (09:42 -0800)] 
gh-112020: Rework socketserver examples to be correct (#129741)

gh-112020: Rework socketserver examples to be correct.

Outdated code updated, the BaseRequestHandler example is now much more
illustrative instead of the bad idea of a single recv() call for TCP.

tested, they now work.

9 months agogh-129668: Fix thread-safety of MemoryError freelist in free threaded build (gh-129704)
Sam Gross [Thu, 6 Feb 2025 17:38:12 +0000 (12:38 -0500)] 
gh-129668: Fix thread-safety of MemoryError freelist in free threaded build (gh-129704)

The MemoryError freelist was not thread-safe in the free threaded build.
Use a mutex to protect accesses to the freelist. Unlike other freelists,
the MemoryError freelist is not performance sensitive.

9 months agoGH-121970: Extract ``implementation_detail`` into a new extension (#129663)
Adam Turner [Thu, 6 Feb 2025 16:53:27 +0000 (16:53 +0000)] 
GH-121970: Extract ``implementation_detail`` into a new extension (#129663)

9 months agoRemove an inaccurate note from `socket.recv` (GH-129733)
Gregory P. Smith [Thu, 6 Feb 2025 16:39:37 +0000 (08:39 -0800)] 
Remove an inaccurate note from `socket.recv` (GH-129733)

Remove an inaccurate note from socket.recv.

9 months agogh-91048: fix `_asyncio.future_discard_from_awaited_by` (#129731)
Kumar Aditya [Thu, 6 Feb 2025 16:35:33 +0000 (22:05 +0530)] 
gh-91048: fix `_asyncio.future_discard_from_awaited_by` (#129731)

fix discard

9 months agogh-91048: fix thread safety for asyncio stack introspection APIs (#129399)
Kumar Aditya [Thu, 6 Feb 2025 16:03:52 +0000 (21:33 +0530)] 
gh-91048: fix thread safety for asyncio stack introspection APIs (#129399)

9 months agogh-129707: Check `Tools/build/compute-changes.py` with `mypy` (#129708)
sobolevn [Thu, 6 Feb 2025 15:47:29 +0000 (18:47 +0300)] 
gh-129707: Check `Tools/build/compute-changes.py` with `mypy` (#129708)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
9 months agogh-128563: A new tail-calling interpreter (GH-128718)
Ken Jin [Thu, 6 Feb 2025 15:21:57 +0000 (23:21 +0800)] 
gh-128563: A new tail-calling interpreter (GH-128718)

Co-authored-by: Garrett Gu <garrettgu777@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
9 months agogh-129694: Add `--parallel-threads` TSAN job to CI (gh-129696)
Sam Gross [Thu, 6 Feb 2025 15:19:00 +0000 (10:19 -0500)] 
gh-129694: Add `--parallel-threads` TSAN job to CI (gh-129696)

For now, this just adds a single test suite to the TSAN CI to be run
with `--parallel-threads`.

9 months agogh-128714: Fix function object races in `__annotate__`, `__annotations__` and `__type...
Xuanteng Huang [Thu, 6 Feb 2025 14:40:50 +0000 (22:40 +0800)] 
gh-128714: Fix function object races in `__annotate__`, `__annotations__` and `__type_params__` in  free-threading build (#129016)

9 months agogh-129643: Fix `PyList_Insert` in free-threading builds (#129680)
sobolevn [Thu, 6 Feb 2025 12:54:40 +0000 (15:54 +0300)] 
gh-129643: Fix `PyList_Insert` in free-threading builds (#129680)

9 months agogh-118915: Fix bad link in documentation (GH-129691)
Miro Hrončok [Thu, 6 Feb 2025 12:34:06 +0000 (13:34 +0100)] 
gh-118915: Fix bad link in documentation (GH-129691)

9 months ago_markupbase.py: Use a permalink for the analysis of MS-Word extensions (GH-129017)
Stan Ulbrych [Thu, 6 Feb 2025 10:40:43 +0000 (10:40 +0000)] 
_markupbase.py: Use a permalink for the analysis of MS-Word extensions (GH-129017)

Update _markupbase.py

9 months agogh-129005: Update _pyio.BytesIO to use bytearray.resize on write (#129702)
Cody Maloney [Thu, 6 Feb 2025 10:18:08 +0000 (02:18 -0800)] 
gh-129005: Update _pyio.BytesIO to use bytearray.resize on write (#129702)

Co-authored-by: Victor Stinner <vstinner@python.org>
9 months agogh-86206: Change IDLE splash line (#129698)
Stan Ulbrych [Thu, 6 Feb 2025 07:55:25 +0000 (07:55 +0000)] 
gh-86206: Change IDLE splash line (#129698)

Change splash line

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
9 months agogh-69001: Replace maintainer email in IDLE credits (#129588)
Stan Ulbrych [Thu, 6 Feb 2025 06:44:50 +0000 (06:44 +0000)] 
gh-69001: Replace maintainer email in IDLE credits (#129588)

Instead, anyone requesting credit should submit a PR with contribution summary.
(Also fix typo in existing name.)

9 months agogh-129201: Use prefetch in GC mark alive phase. (gh-129203)
Neil Schemenauer [Wed, 5 Feb 2025 19:38:30 +0000 (11:38 -0800)] 
gh-129201: Use prefetch in GC mark alive phase. (gh-129203)

For the free-threaded version of the cyclic GC, restructure the "mark alive" phase to use software prefetch instructions.  This gives a speedup in most cases when the number of objects is large enough.  The prefetching is enabled conditionally based on the number of long-lived objects the GC finds.

9 months agogh-129559: Add `bytearray.resize()` (GH-129560)
Cody Maloney [Wed, 5 Feb 2025 19:33:17 +0000 (11:33 -0800)] 
gh-129559: Add `bytearray.resize()` (GH-129560)

Add bytearray.resize() which wraps PyByteArray_Resize.

Make negative size passed to resize exception/error rather than crash in optimized builds.

9 months agoConvert change detection to a Python script (#129627)
Adam Turner [Wed, 5 Feb 2025 16:39:42 +0000 (16:39 +0000)] 
Convert change detection to a Python script (#129627)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
9 months agogh-127833: Docs: Add a `grammar-snippet` directive & replace `productionlist` (GH...
Petr Viktorin [Wed, 5 Feb 2025 15:12:23 +0000 (16:12 +0100)] 
gh-127833: Docs: Add a `grammar-snippet` directive & replace `productionlist` (GH-127835)

As a first step toward aligning the grammar documentation with Python's actual
grammar, this overrides the ReST `productionlist` directive to:
- use `:` instead of the `::=` symbol
- add syntax highlighting for strings (using a Pygments highlighting class)

All links and link targets should be preserved. (Unfortunately, this reaches
into some Sphinx internals; I don't see a better way to do exactly what
Sphinx does.)

This also adds a new directive, `grammar-snippet`, which formats the snippet
almost exactly like what's in the source, modulo syntax highlighting and
keeping the backtick character to mark links to other rules.
This will allow formatting the snippets as in the grammar file
(file:///home/encukou/dev/cpython/Doc/build/html/reference/grammar.html).

The new directive is applied to two simple rules in toplevel_components.rst

---------

Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: William Ferreira <wqferr@gmail.com>
Co-authored-by: bswck <bartoszpiotrslawecki@gmail.com>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
9 months agogh-129354: Cleanup test_coroutines (#129684)
Victor Stinner [Wed, 5 Feb 2025 11:43:46 +0000 (12:43 +0100)] 
gh-129354: Cleanup test_coroutines (#129684)

Remove unused variables.

9 months agogh-129354: Use PyErr_FormatUnraisable() function (#129523)
Victor Stinner [Wed, 5 Feb 2025 10:31:59 +0000 (11:31 +0100)] 
gh-129354: Use PyErr_FormatUnraisable() function (#129523)

Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().

Update tests:

* test_coroutines
* test_exceptions
* test_generators
* test_struct

9 months agogh-128911: Use PyImport_ImportModuleAttr() function (#129657)
Victor Stinner [Wed, 5 Feb 2025 10:03:58 +0000 (11:03 +0100)] 
gh-128911: Use PyImport_ImportModuleAttr() function (#129657)

* Replace PyImport_ImportModule() + PyObject_GetAttr() with
  PyImport_ImportModuleAttr().
* Replace PyImport_ImportModule() + PyObject_GetAttrString() with
  PyImport_ImportModuleAttrString().

9 months agogh-129643: fix thread safety of `PyList_SetItem` (#129644)
Kumar Aditya [Wed, 5 Feb 2025 07:38:02 +0000 (13:08 +0530)] 
gh-129643: fix thread safety of `PyList_SetItem` (#129644)

9 months agogh-104400: pygettext: Prepare to replace TokenEater with a NodeVisitor (#129672)
Tomas R. [Tue, 4 Feb 2025 22:59:23 +0000 (23:59 +0100)] 
gh-104400: pygettext: Prepare to replace TokenEater with a NodeVisitor (#129672)

* Update the module docstring
* Move ``key_for`` inside the class
* Move ``write_pot_file`` outside the class

9 months agogh-127933: Add option to run regression tests in parallel (gh-128003)
Sam Gross [Tue, 4 Feb 2025 22:44:59 +0000 (17:44 -0500)] 
gh-127933: Add option to run regression tests in parallel (gh-128003)

This adds a new command line argument, `--parallel-threads` to the
regression test runner to allow it to run individual tests in multiple
threads in parallel in order to find multithreading bugs.

Some tests pass when run with `--parallel-threads`, but there's still
more work before the entire suite passes.

9 months agogh-129660: Do not use test_embed in PGO profile builds (#129661)
neonene [Tue, 4 Feb 2025 19:33:07 +0000 (04:33 +0900)] 
gh-129660: Do not use test_embed in PGO profile builds (#129661)

9 months agogh-129646: Update the locale alias mapping (#129647)
Serhiy Storchaka [Tue, 4 Feb 2025 15:22:05 +0000 (17:22 +0200)] 
gh-129646: Update the locale alias mapping (#129647)

* gh-129646: Update the locale alias mapping

* Add a NEWS file.

9 months agogh-129354: Use PyErr_FormatUnraisable() function (#129656)
Victor Stinner [Tue, 4 Feb 2025 15:21:10 +0000 (16:21 +0100)] 
gh-129354: Use PyErr_FormatUnraisable() function (#129656)

Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().

9 months agogh-128772: Fix pydoc for methods with __module__ is None (GH-129177)
Serhiy Storchaka [Tue, 4 Feb 2025 14:25:49 +0000 (16:25 +0200)] 
gh-128772: Fix pydoc for methods with __module__ is None (GH-129177)

9 months agogh-129350: Make tests for glob with trailing slash more strict (GH-129376)
Serhiy Storchaka [Tue, 4 Feb 2025 14:24:22 +0000 (16:24 +0200)] 
gh-129350: Make tests for glob with trailing slash more strict (GH-129376)

Test that the trailing pathname separator is preserved.

Multiple trailing pathname separators are only preserved if the pattern
does not contain metacharacters, otherwise only one trailing pathname
separator is preserved. This is rather an implementation detail.

9 months agoUse roles :data: and :const: for referencing module variables (GH-129507)
Serhiy Storchaka [Tue, 4 Feb 2025 14:16:41 +0000 (16:16 +0200)] 
Use roles :data: and :const: for referencing module variables (GH-129507)

9 months agoGH-128682: Mark two more macros as escaping. (GH-129645)
Mark Shannon [Tue, 4 Feb 2025 14:00:51 +0000 (14:00 +0000)] 
GH-128682: Mark two more macros as escaping. (GH-129645)

Expand out SETLOCAL so that code generator can see the decref. Mark Py_CLEAR as escaping

9 months agoGH-128682: Spill the stack pointer in labels, as well as instructions (GH-129618)
Mark Shannon [Tue, 4 Feb 2025 12:18:31 +0000 (12:18 +0000)] 
GH-128682: Spill the stack pointer in labels, as well as instructions (GH-129618)

9 months agogh-126835: Fix reference leak in `Python/flowgrapc.::optimize_if_const_subscr` ...
Yan Yanchii [Tue, 4 Feb 2025 10:38:06 +0000 (11:38 +0100)] 
gh-126835: Fix reference leak in `Python/flowgrapc.::optimize_if_const_subscr`  (#129634)

9 months agogh-126835: Move constant subscript folding to CFG (#129568)
Yan Yanchii [Tue, 4 Feb 2025 08:10:55 +0000 (09:10 +0100)] 
gh-126835: Move constant subscript folding to CFG (#129568)

Move folding of constant subscription from AST optimizer to CFG.

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
9 months agogh-111637: Clarify MIME type recognition behavior in mimetypes documentation (GH...
donBarbos [Mon, 3 Feb 2025 16:42:12 +0000 (20:42 +0400)] 
gh-111637: Clarify MIME type recognition behavior in mimetypes documentation (GH-129546)

9 months agoGH-128563: Generate `opcode = ...` in instructions that need `opcode` (GH-129608)
Mark Shannon [Mon, 3 Feb 2025 15:09:21 +0000 (15:09 +0000)] 
GH-128563: Generate `opcode = ...` in instructions that need `opcode` (GH-129608)

* Remove support for GO_TO_INSTRUCTION

9 months agoGH-128682: Make `PyStackRef_CLOSE` escaping. (GH-129404)
Mark Shannon [Mon, 3 Feb 2025 12:41:32 +0000 (12:41 +0000)] 
GH-128682: Make `PyStackRef_CLOSE` escaping. (GH-129404)

9 months agogh-129354: Use PyErr_FormatUnraisable() function (#129524)
Victor Stinner [Mon, 3 Feb 2025 12:10:18 +0000 (13:10 +0100)] 
gh-129354: Use PyErr_FormatUnraisable() function (#129524)

Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().

Update test_sqlite3 tests.

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
9 months agogh-101944: Clarify PyModule_AddObjectRef() documentation (#129433)
Victor Stinner [Mon, 3 Feb 2025 11:55:22 +0000 (12:55 +0100)] 
gh-101944: Clarify PyModule_AddObjectRef() documentation (#129433)

9 months agogh-129407: Clarify that a `SystemError` isn't always CPython's fault (#129410)
Peter Bierma [Mon, 3 Feb 2025 11:46:13 +0000 (06:46 -0500)] 
gh-129407: Clarify that a `SystemError` isn't always CPython's fault (#129410)

9 months agogh-129342: Explain how to replace Py_GetProgramName() in C (#129361)
Victor Stinner [Mon, 3 Feb 2025 11:36:41 +0000 (12:36 +0100)] 
gh-129342: Explain how to replace Py_GetProgramName() in C (#129361)

9 months agogh-81340: Use copy_file_range in shutil.copyfile copy functions (GH-93152)
Illia Volochii [Mon, 3 Feb 2025 10:23:27 +0000 (12:23 +0200)] 
gh-81340: Use copy_file_range in shutil.copyfile copy functions (GH-93152)

This allows the underlying file system an opportunity to optimise or avoid the actual copy.

9 months agoGH-129231: Group executable JIT code in memory (GH-129232)
Diego Russo [Sun, 2 Feb 2025 23:19:55 +0000 (23:19 +0000)] 
GH-129231: Group executable JIT code in memory (GH-129232)

9 months agoGH-128842: Collect JIT memory stats (GH-128941)
Diego Russo [Sun, 2 Feb 2025 23:17:53 +0000 (23:17 +0000)] 
GH-128842: Collect JIT memory stats (GH-128941)

9 months agoGH-128872: Remove unused argument from _PyCode_Quicken (GH-128873)
Yan Yanchii [Sun, 2 Feb 2025 23:09:30 +0000 (00:09 +0100)] 
GH-128872: Remove unused argument from _PyCode_Quicken (GH-128873)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
9 months agogh-105875: amend sqlite3 docstring wrt. SQLite requirement (#129599)
Erlend E. Aasland [Sun, 2 Feb 2025 23:03:54 +0000 (00:03 +0100)] 
gh-105875: amend sqlite3 docstring wrt. SQLite requirement (#129599)

9 months agogh-91417: Remove PySequence_Fast() from the limited C API (#129398)
Victor Stinner [Sun, 2 Feb 2025 22:17:30 +0000 (23:17 +0100)] 
gh-91417: Remove PySequence_Fast() from the limited C API (#129398)

The function never worked with the limited C API. It was added by
mistake.

9 months agoGH-121970: Extract ``misc_news`` into a new extension (#129577)
Adam Turner [Sun, 2 Feb 2025 16:17:02 +0000 (16:17 +0000)] 
GH-121970: Extract ``misc_news`` into a new extension (#129577)

9 months agogh-126609: Allow translating the ``availability`` directive (#129549)
Adam Turner [Sun, 2 Feb 2025 16:12:01 +0000 (16:12 +0000)] 
gh-126609: Allow translating the ``availability`` directive (#129549)

9 months agogh-115514: Fix incomplete writes after close while using ssl in asyncio(#128037)
Vojtěch Boček [Sun, 2 Feb 2025 15:11:25 +0000 (16:11 +0100)] 
gh-115514: Fix incomplete writes after close while using ssl in asyncio(#128037)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
9 months agoRevert "gh-129005: Align FileIO.readall() allocation (#129458)" (#129572)
Cody Maloney [Sun, 2 Feb 2025 14:59:15 +0000 (06:59 -0800)] 
Revert "gh-129005: Align FileIO.readall() allocation (#129458)" (#129572)

This reverts commit f927204f64b3f8dbecec784e05bc8e25d2a78b2e.

9 months agogh-104400: Remove ``fintl.gettext`` from pygettext (#129580)
Adam Turner [Sun, 2 Feb 2025 14:30:34 +0000 (14:30 +0000)] 
gh-104400: Remove ``fintl.gettext`` from pygettext (#129580)

The ``fintl`` module is never installed or tested, meaning that the
fallback identity function is unconditionally used for ``_()``.
This means we can simplify, converting the docstring to a real
docstring, and converting some other strings to f-strings.

We also convert the module to UTF-8, sort imports,
and remove the history comment, which was last updated in 2002.
Consult the git history for a more accurate summary of changes.

9 months agogh-129539: Reorganize posixmodule.c header (#129558)
Victor Stinner [Sun, 2 Feb 2025 09:16:48 +0000 (10:16 +0100)] 
gh-129539: Reorganize posixmodule.c header (#129558)

Add sections: Python includes, system includes, etc.

Add a comment explaining why an include is needed.

9 months agogh-119461: Restore the testSocket VSOCK skipUnless removed by PR #119465 (#129561)
Gregory P. Smith [Sun, 2 Feb 2025 04:46:56 +0000 (20:46 -0800)] 
gh-119461: Restore the testSocket VSOCK skipUnless removed by PR #119465 (#129561)

Restore the skipUnless removed by #119465.

This test can only pass on virtual machines, not actual machines.

actual machines see:

```
    self.cli.connect((cid, VSOCKPORT))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
OSError: [Errno 19] No such device
```

Reproduced on (Linux) Ubuntu 24.04.1 running 6.8.0-52-generic.

9 months agogh-126022: Replace TeX quotation marks with ``"`` in Doc/license.rst (#129535)
Stan Ulbrych [Sat, 1 Feb 2025 16:49:45 +0000 (16:49 +0000)] 
gh-126022: Replace TeX quotation marks with ``"`` in  Doc/license.rst (#129535)

9 months agogh-93649: Move _testcapi tests to specific files (#129544)
Victor Stinner [Sat, 1 Feb 2025 12:39:16 +0000 (13:39 +0100)] 
gh-93649: Move _testcapi tests to specific files (#129544)

Move many functions from _testcapimodule.c into more specific files
in Modules/_testcapi/.

In moved code:

* Replace get_testerror() with PyExc_AssertionError.
* Replace raiseTestError() with
  PyErr_Format(PyExc_AssertionError, ...).

9 months agogh-126835: Move optimization of constant sequence creation from codegen to CFG (...
Kirill Podoprigora [Sat, 1 Feb 2025 11:39:44 +0000 (11:39 +0000)] 
gh-126835: Move optimization of constant sequence creation from codegen to CFG (#129426)

Codegen phase has an optimization that transforms
```
LOAD_CONST x
LOAD_CONST y
LOAD_CONXT z
BUILD_LIST/BUILD_SET (3)
```
->
```
BUILD_LIST/BUILD_SET (0)
LOAD_CONST (x, y, z)
LIST_EXTEND/SET_UPDATE 1
```
This optimization has now been moved to CFG phase to make #128802 work.

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Yan Yanchii <yyanchiy@gmail.com>