]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
8 months agogh-91132: Update macOS installer to use ncurses 6.5. (#129990)
Ned Deily [Tue, 11 Feb 2025 04:48:12 +0000 (23:48 -0500)] 
gh-91132: Update macOS installer to use ncurses 6.5. (#129990)

8 months agogh-123299: Copyedit "What's New in Python 3.14" (#129970)
Hugo van Kemenade [Mon, 10 Feb 2025 21:46:36 +0000 (23:46 +0200)] 
gh-123299: Copyedit "What's New in Python 3.14" (#129970)

8 months agoClarify baseline for new interpreter (GH-129972)
Ken Jin [Mon, 10 Feb 2025 19:07:24 +0000 (03:07 +0800)] 
Clarify baseline for new interpreter (GH-129972)

8 months agogh-46236: Document `PyUnicode_DecodeCodePageStateful` (GH-127934)
Yuki Kobayashi [Mon, 10 Feb 2025 16:17:37 +0000 (01:17 +0900)] 
gh-46236: Document `PyUnicode_DecodeCodePageStateful` (GH-127934)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
8 months agogh-127712: Fix `secure` argument of `logging.handlers.SMTPHandler` (GH-127726)
s-hamann [Mon, 10 Feb 2025 12:34:27 +0000 (12:34 +0000)] 
gh-127712: Fix `secure` argument of `logging.handlers.SMTPHandler` (GH-127726)

GH-127712: Fix `secure` argument of `logging.handlers.SMTPHandler`

Python 3.12 removed support for the `keyfile` and `certfile` parameters
in `smtplib.SMTP.starttls()`, requiring a `ssl.SSLContext` instead.
`SMTPHandler` now creates a context from the `secure` tuple and passes
that to `starttls`.

8 months agogh-129289: fix crash when task finalizer is not called in asyncio (#129840)
Kumar Aditya [Mon, 10 Feb 2025 11:33:59 +0000 (17:03 +0530)] 
gh-129289: fix crash when task finalizer is not called in asyncio (#129840)

8 months agogh-129143: Fix incorrect documentation for logging.Handler.close(). (GH-129950)
Vinay Sajip [Mon, 10 Feb 2025 11:13:52 +0000 (11:13 +0000)] 
gh-129143: Fix incorrect documentation for logging.Handler.close(). (GH-129950)

8 months agogh-129583: update bundled pip to 25.0.1 (#129909)
Stéphane Bidoul [Mon, 10 Feb 2025 10:21:04 +0000 (11:21 +0100)] 
gh-129583: update bundled pip to 25.0.1 (#129909)

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

This fixes UBSan failures for `dbmobject`.

In addition, we perform some minor cleanup changes such as renaming
some `args` parameter to `dummy` in some `METH_NOARGS` methods and
suppressing an unused return value in `_dbm_module_free`.

8 months agogh-126554: correct detection of `gcc` for `TestNullDlsym.test_null_dlsym` (GH-129872)
Peter Marko [Mon, 10 Feb 2025 09:51:56 +0000 (10:51 +0100)] 
gh-126554: correct detection of `gcc` for `TestNullDlsym.test_null_dlsym` (GH-129872)

In case gcc is not available, the test will fail with FileNotFoundError.
So catch the exception to skip the test correctly.

Signed-off-by: Peter Marko <peter.marko@siemens.com>
8 months agogh-128002: add fast path for native tasks in `asyncio.all_tasks` (#129943)
Kumar Aditya [Mon, 10 Feb 2025 09:34:33 +0000 (15:04 +0530)] 
gh-128002: add fast path for native tasks in `asyncio.all_tasks` (#129943)

8 months agogh-128002: simplify `asyncio.all_tasks` to use `PyList_Extend` instead of manual...
Kumar Aditya [Mon, 10 Feb 2025 08:56:32 +0000 (14:26 +0530)] 
gh-128002: simplify `asyncio.all_tasks` to use `PyList_Extend` instead of manual iteration (#129942)

8 months agoFix typo in 3.14 `pdb` whatsnew entry (#129886)
Victorien [Mon, 10 Feb 2025 06:17:05 +0000 (07:17 +0100)] 
Fix typo in 3.14 `pdb` whatsnew entry (#129886)

8 months agogh-68400: Remove outdated 2.7 comment (#129919)
Stan Ulbrych [Mon, 10 Feb 2025 04:53:32 +0000 (04:53 +0000)] 
gh-68400: Remove outdated 2.7 comment (#129919)

8 months agogh-129603: Don't segfault if sqlite3.Row description is None (#129604)
Erlend E. Aasland [Sun, 9 Feb 2025 23:27:28 +0000 (00:27 +0100)] 
gh-129603: Don't segfault if sqlite3.Row description is None (#129604)

8 months agoFix typo in `enum` documentation (#129920)
Victorien [Sun, 9 Feb 2025 21:48:11 +0000 (22:48 +0100)] 
Fix typo in `enum` documentation (#129920)

8 months agogh-129870: Skip test_dump_virtual_tables if SQLite lacks FTS4 support (#129913)
Erlend E. Aasland [Sun, 9 Feb 2025 20:43:23 +0000 (21:43 +0100)] 
gh-129870: Skip test_dump_virtual_tables if SQLite lacks FTS4 support (#129913)

8 months agogh-126835: Make CFG optimizer skip over NOP's when looking for const sequence constru...
Yan Yanchii [Sun, 9 Feb 2025 18:00:41 +0000 (19:00 +0100)] 
gh-126835: Make CFG optimizer skip over NOP's when looking for const sequence construction (#129703)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
8 months agoTrigger tail call CI on more files (GH-129906)
Ken Jin [Sun, 9 Feb 2025 16:52:58 +0000 (00:52 +0800)] 
Trigger tail call CI on more files (GH-129906)

8 months agogh-129892: Doc: Remove unnecessary role directive in graphlib.py (#129896)
Nikola Savic [Sun, 9 Feb 2025 15:22:57 +0000 (16:22 +0100)] 
gh-129892: Doc: Remove unnecessary role directive in graphlib.py (#129896)

Change `:exec:ValueError` to `ValueError` in `TopologicalSorter.done()` docstring

8 months agogh-129874: improve test_events to use correct task implementation (#129891)
Kumar Aditya [Sun, 9 Feb 2025 13:06:16 +0000 (18:36 +0530)] 
gh-129874: improve test_events to use correct task implementation (#129891)

8 months agogh-129874: improve `test_tasks` in asyncio to use correct internal functions (#129890)
Kumar Aditya [Sun, 9 Feb 2025 13:02:11 +0000 (18:32 +0530)] 
gh-129874: improve `test_tasks` in asyncio to use correct internal functions (#129890)

8 months agogh-129874: improve asyncio tests to use correct internal functions (#129887)
Kumar Aditya [Sun, 9 Feb 2025 12:05:39 +0000 (17:35 +0530)] 
gh-129874: improve asyncio tests to use correct internal functions  (#129887)

8 months agoGH-125413: Move `pathlib.Path.copy()` implementation alongside `Path.info` (#129856)
Barney Gale [Sun, 9 Feb 2025 12:05:23 +0000 (12:05 +0000)] 
GH-125413: Move `pathlib.Path.copy()` implementation alongside `Path.info` (#129856)

Move pathlib's private `CopyReader`, `LocalCopyReader`, `CopyWriter` and
`LocalCopyWriter` classes into `pathlib._os`, where they can live alongside
the low-level copying functions (`copyfileobj()` etc) and high-level path
querying interface (`PathInfo`).

This sets the stage for merging `LocalCopyReader` into `PathInfo`.

No change of behaviour; just moving some code around.

8 months agogh-129874: avoid mixing pure python and C implementation of asyncio (#129875)
Kumar Aditya [Sun, 9 Feb 2025 10:27:00 +0000 (15:57 +0530)] 
gh-129874: avoid mixing pure python and C implementation of asyncio (#129875)

8 months agogh-129873: IDLE: Improve help.py's method of parsing HTML (#129859)
Stan Ulbrych [Sun, 9 Feb 2025 08:17:35 +0000 (08:17 +0000)] 
gh-129873: IDLE: Improve help.py's method of parsing HTML (#129859)

In `help.copy_strip`, only copy the text `<section>`.  In `help.HelpParser.handle_starttag` and elsewhere, remove code to skip the no longer present html.  Add a reminder at the top of idle.rst to run copy_strip after changes.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
8 months agogh-129876: Initial 3.14 News3.txt entries (#129881)
Terry Jan Reedy [Sun, 9 Feb 2025 07:24:34 +0000 (02:24 -0500)] 
gh-129876: Initial 3.14 News3.txt entries (#129881)

8 months agogh-112953: Update news to finish 3.13 as main (#129877)
Terry Jan Reedy [Sun, 9 Feb 2025 06:13:43 +0000 (01:13 -0500)] 
gh-112953: Update news to finish 3.13 as main (#129877)

Entry for patch to 3.13.rc3

8 months agoProvide curframe_locals for backward compatibility but deprecate it (#125951)
Tian Gao [Sat, 8 Feb 2025 23:35:28 +0000 (18:35 -0500)] 
Provide curframe_locals for backward compatibility but deprecate it (#125951)

8 months agogh-128657: Run test_hashlib with `--parallel-threads` (GH-129833)
Sam Gross [Sat, 8 Feb 2025 20:12:21 +0000 (15:12 -0500)] 
gh-128657: Run test_hashlib with `--parallel-threads` (GH-129833)

* gh-128657: Run test_hashlib with `--parallel-threads`

This catches the race in `py_digest_by_name` that is fixed separately
in gh-128886.

* Adjust assertion order

8 months agogh-64414: mention AF_INET6 and IPv6 in socketserver docs. (#129866)
Gregory P. Smith [Sat, 8 Feb 2025 20:06:28 +0000 (12:06 -0800)] 
gh-64414: mention AF_INET6 and IPv6 in socketserver docs. (#129866)

mention AF_INET6 and IPv6 in socketserver docs.

8 months agoDocs: more explanation of the implications of new tail-call interpreter (GH-129863)
Ned Batchelder [Sat, 8 Feb 2025 19:28:35 +0000 (12:28 -0700)] 
Docs: more explanation of the implications of new tail-call interpreter (GH-129863)

Co-authored-by: Ken Jin <kenjin4096@gmail.com>
8 months agogh-129699: Add description to IDLE doc title (#129727)
Stan Ulbrych [Sat, 8 Feb 2025 19:26:07 +0000 (19:26 +0000)] 
gh-129699: Add description to IDLE doc title (#129727)

Also extend the 'idlelib' section header. These additions affect both the displayed idle.html file and the contents.html file displayed by clicking the Complete table of contents link on the main docs.python.org page. (The module index entries are generated from the module name and synopsis within module files.)
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
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)

8 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)

8 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

8 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.

8 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)

8 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>
8 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>
8 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)

8 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.