Skip to content

Commit f9bd6ef

Browse files
Merge branch 'main' into fix-issue-112632
2 parents c446aa1 + 29f8a67 commit f9bd6ef

File tree

107 files changed

+4228
-3530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+4228
-3530
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ jobs:
247247
- true
248248
os:
249249
- ubuntu-24.04
250-
- ubuntu-24.04-arm
250+
- ubuntu-22.04-arm
251251
exclude:
252252
# Do not test BOLT with free-threading, to conserve resources
253253
- bolt: true
254254
free-threading: true
255255
# BOLT currently crashes during instrumentation on aarch64
256-
- os: ubuntu-24.04-arm
256+
- os: ubuntu-22.04-arm
257257
bolt: true
258258
uses: ./.github/workflows/reusable-ubuntu.yml
259259
with:

.github/workflows/jit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
runner: ubuntu-24.04
8787
- target: aarch64-unknown-linux-gnu/gcc
8888
architecture: aarch64
89-
runner: ubuntu-24.04-arm
89+
runner: ubuntu-22.04-arm
9090
steps:
9191
- uses: actions/checkout@v4
9292
with:

.github/workflows/tail-call.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
runner: ubuntu-24.04
6363
- target: aarch64-unknown-linux-gnu/gcc
6464
architecture: aarch64
65-
runner: ubuntu-24.04-arm
65+
runner: ubuntu-22.04-arm
6666
steps:
6767
- uses: actions/checkout@v4
6868
with:

Doc/library/calendar.rst

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,13 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
166166
the specified width, representing an empty day. The *weekday* parameter
167167
is unused.
168168

169-
.. method:: formatweek(theweek, w=0, highlight_day=None)
169+
.. method:: formatweek(theweek, w=0)
170170

171171
Return a single week in a string with no newline. If *w* is provided, it
172172
specifies the width of the date columns, which are centered. Depends
173173
on the first weekday as specified in the constructor or set by the
174174
:meth:`setfirstweekday` method.
175175

176-
.. versionchanged:: 3.14
177-
If *highlight_day* is given, this date is highlighted in color.
178-
This can be :ref:`controlled using environment variables
179-
<using-on-controlling-color>`.
180-
181176

182177
.. method:: formatweekday(weekday, width)
183178

@@ -193,19 +188,14 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
193188
settings and are padded to the specified width.
194189

195190

196-
.. method:: formatmonth(theyear, themonth, w=0, l=0, highlight_day=None)
191+
.. method:: formatmonth(theyear, themonth, w=0, l=0)
197192

198193
Return a month's calendar in a multi-line string. If *w* is provided, it
199194
specifies the width of the date columns, which are centered. If *l* is
200195
given, it specifies the number of lines that each week will use. Depends
201196
on the first weekday as specified in the constructor or set by the
202197
:meth:`setfirstweekday` method.
203198

204-
.. versionchanged:: 3.14
205-
If *highlight_day* is given, this date is highlighted in color.
206-
This can be :ref:`controlled using environment variables
207-
<using-on-controlling-color>`.
208-
209199

210200
.. method:: formatmonthname(theyear, themonth, width=0, withyear=True)
211201

@@ -220,7 +210,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
220210
Print a month's calendar as returned by :meth:`formatmonth`.
221211

222212

223-
.. method:: formatyear(theyear, w=2, l=1, c=6, m=3, highlight_day=None)
213+
.. method:: formatyear(theyear, w=2, l=1, c=6, m=3)
224214

225215
Return a *m*-column calendar for an entire year as a multi-line string.
226216
Optional parameters *w*, *l*, and *c* are for date column width, lines per
@@ -229,11 +219,6 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
229219
:meth:`setfirstweekday` method. The earliest year for which a calendar
230220
can be generated is platform-dependent.
231221

232-
.. versionchanged:: 3.14
233-
If *highlight_day* is given, this date is highlighted in color.
234-
This can be :ref:`controlled using environment variables
235-
<using-on-controlling-color>`.
236-
237222

238223
.. method:: pryear(theyear, w=2, l=1, c=6, m=3)
239224

Doc/library/ctypes.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,28 @@ the shared library name at development time, and hardcode that into the wrapper
14061406
module instead of using :func:`~ctypes.util.find_library` to locate the library at runtime.
14071407

14081408

1409+
.. _ctypes-listing-loaded-shared-libraries:
1410+
1411+
Listing loaded shared libraries
1412+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1413+
1414+
When writing code that relies on code loaded from shared libraries, it can be
1415+
useful to know which shared libraries have already been loaded into the current
1416+
process.
1417+
1418+
The :mod:`!ctypes.util` module provides the :func:`~ctypes.util.dllist` function,
1419+
which calls the different APIs provided by the various platforms to help determine
1420+
which shared libraries have already been loaded into the current process.
1421+
1422+
The exact output of this function will be system dependent. On most platforms,
1423+
the first entry of this list represents the current process itself, which may
1424+
be an empty string.
1425+
For example, on glibc-based Linux, the return may look like::
1426+
1427+
>>> from ctypes.util import dllist
1428+
>>> dllist()
1429+
['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-linux-gnu/libc.so.6', ... ]
1430+
14091431
.. _ctypes-loading-shared-libraries:
14101432

14111433
Loading shared libraries
@@ -2083,6 +2105,20 @@ Utility functions
20832105
.. availability:: Windows
20842106

20852107

2108+
.. function:: dllist()
2109+
:module: ctypes.util
2110+
2111+
Try to provide a list of paths of the shared libraries loaded into the current
2112+
process. These paths are not normalized or processed in any way. The function
2113+
can raise :exc:`OSError` if the underlying platform APIs fail.
2114+
The exact functionality is system dependent.
2115+
2116+
On most platforms, the first element of the list represents the current
2117+
executable file. It may be an empty string.
2118+
2119+
.. availability:: Windows, macOS, iOS, glibc, BSD libc, musl
2120+
.. versionadded:: next
2121+
20862122
.. function:: FormatError([code])
20872123

20882124
Returns a textual description of the error code *code*. If no error code is

Doc/library/dis.rst

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -703,15 +703,8 @@ not have to be) the original ``STACK[-2]``.
703703
STACK.append(lhs op rhs)
704704

705705
.. versionadded:: 3.11
706-
707-
708-
.. opcode:: BINARY_SUBSCR
709-
710-
Implements::
711-
712-
key = STACK.pop()
713-
container = STACK.pop()
714-
STACK.append(container[key])
706+
.. versionchanged:: 3.14
707+
With oparg :``NB_SUBSCR``, implements binary subscript (replaces opcode ``BINARY_SUBSCR``)
715708

716709

717710
.. opcode:: STORE_SUBSCR

Doc/library/idle.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _idle:
22

3-
IDLE
4-
====
3+
IDLE --- Python editor and shell
4+
================================
55

66
.. moduleauthor:: Guido van Rossum <[email protected]>
77

@@ -971,8 +971,8 @@ information. The only current default extension is zzdummy, an example
971971
also used for testing.
972972

973973

974-
idlelib
975-
-------
974+
idlelib --- implementation of IDLE application
975+
----------------------------------------------
976976

977977
.. module:: idlelib
978978
:synopsis: Implementation package for the IDLE shell/editor.

Doc/library/imaplib.rst

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
.. changes for IMAP4_SSL by Tino Lange <[email protected]>, March 2002
1111
.. changes for IMAP4_stream by Piers Lauder <[email protected]>,
1212
November 2002
13+
.. changes for IMAP4 IDLE by Forest <[email protected]>, August 2024
1314
1415
**Source code:** :source:`Lib/imaplib.py`
1516

@@ -187,7 +188,7 @@ However, the *password* argument to the ``LOGIN`` command is always quoted. If
187188
you want to avoid having an argument string quoted (eg: the *flags* argument to
188189
``STORE``) then enclose the string in parentheses (eg: ``r'(\Deleted)'``).
189190

190-
Each command returns a tuple: ``(type, [data, ...])`` where *type* is usually
191+
Most commands return a tuple: ``(type, [data, ...])`` where *type* is usually
191192
``'OK'`` or ``'NO'``, and *data* is either the text from the command response,
192193
or mandated results from the command. Each *data* is either a ``bytes``, or a
193194
tuple. If a tuple, then the first part is the header of the response, and the
@@ -307,6 +308,93 @@ An :class:`IMAP4` instance has the following methods:
307308
of the IMAP4 QUOTA extension defined in rfc2087.
308309

309310

311+
.. method:: IMAP4.idle(duration=None)
312+
313+
Return an :class:`!Idler`: an iterable context manager implementing the
314+
IMAP4 ``IDLE`` command as defined in :rfc:`2177`.
315+
316+
The returned object sends the ``IDLE`` command when activated by the
317+
:keyword:`with` statement, produces IMAP untagged responses via the
318+
:term:`iterator` protocol, and sends ``DONE`` upon context exit.
319+
320+
All untagged responses that arrive after sending the ``IDLE`` command
321+
(including any that arrive before the server acknowledges the command) will
322+
be available via iteration. Any leftover responses (those not iterated in
323+
the :keyword:`with` context) can be retrieved in the usual way after
324+
``IDLE`` ends, using :meth:`IMAP4.response`.
325+
326+
Responses are represented as ``(type, [data, ...])`` tuples, as described
327+
in :ref:`IMAP4 Objects <imap4-objects>`.
328+
329+
The *duration* argument sets a maximum duration (in seconds) to keep idling,
330+
after which any ongoing iteration will stop. It can be an :class:`int` or
331+
:class:`float`, or ``None`` for no time limit.
332+
Callers wishing to avoid inactivity timeouts on servers that impose them
333+
should keep this at most 29 minutes (1740 seconds).
334+
Requires a socket connection; *duration* must be ``None`` on
335+
:class:`IMAP4_stream` connections.
336+
337+
.. code-block:: pycon
338+
339+
>>> with M.idle(duration=29 * 60) as idler:
340+
... for typ, data in idler:
341+
... print(typ, data)
342+
...
343+
EXISTS [b'1']
344+
RECENT [b'1']
345+
346+
347+
.. method:: Idler.burst(interval=0.1)
348+
349+
Yield a burst of responses no more than *interval* seconds apart
350+
(expressed as an :class:`int` or :class:`float`).
351+
352+
This :term:`generator` is an alternative to iterating one response at a
353+
time, intended to aid in efficient batch processing. It retrieves the
354+
next response along with any immediately available subsequent responses.
355+
(For example, a rapid series of ``EXPUNGE`` responses after a bulk
356+
delete.)
357+
358+
Requires a socket connection; does not work on :class:`IMAP4_stream`
359+
connections.
360+
361+
.. code-block:: pycon
362+
363+
>>> with M.idle() as idler:
364+
... # get a response and any others following by < 0.1 seconds
365+
... batch = list(idler.burst())
366+
... print(f'processing {len(batch)} responses...')
367+
... print(batch)
368+
...
369+
processing 3 responses...
370+
[('EXPUNGE', [b'2']), ('EXPUNGE', [b'1']), ('RECENT', [b'0'])]
371+
372+
.. tip::
373+
374+
The ``IDLE`` context's maximum duration, as passed to
375+
:meth:`IMAP4.idle`, is respected when waiting for the first response
376+
in a burst. Therefore, an expired :class:`!Idler` will cause this
377+
generator to return immediately without producing anything. Callers
378+
should consider this if using it in a loop.
379+
380+
381+
.. note::
382+
383+
The iterator returned by :meth:`IMAP4.idle` is usable only within a
384+
:keyword:`with` statement. Before or after that context, unsolicited
385+
responses are collected internally whenever a command finishes, and can
386+
be retrieved with :meth:`IMAP4.response`.
387+
388+
.. note::
389+
390+
The :class:`!Idler` class name and structure are internal interfaces,
391+
subject to change. Calling code can rely on its context management,
392+
iteration, and public method to remain stable, but should not subclass,
393+
instantiate, compare, or otherwise directly reference the class.
394+
395+
.. versionadded:: next
396+
397+
310398
.. method:: IMAP4.list([directory[, pattern]])
311399

312400
List mailbox names in *directory* matching *pattern*. *directory* defaults to

Doc/library/pathlib.rst

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,38 @@ Querying file type and status
11771177
.. versionadded:: 3.5
11781178

11791179

1180+
.. attribute:: Path.info
1181+
1182+
A :class:`~pathlib.types.PathInfo` object that supports querying file type
1183+
information. The object exposes methods that cache their results, which can
1184+
help reduce the number of system calls needed when switching on file type.
1185+
For example::
1186+
1187+
>>> p = Path('src')
1188+
>>> if p.info.is_symlink():
1189+
... print('symlink')
1190+
... elif p.info.is_dir():
1191+
... print('directory')
1192+
... elif p.info.exists():
1193+
... print('something else')
1194+
... else:
1195+
... print('not found')
1196+
...
1197+
directory
1198+
1199+
If the path was generated from :meth:`Path.iterdir` then this attribute is
1200+
initialized with some information about the file type gleaned from scanning
1201+
the parent directory. Merely accessing :attr:`Path.info` does not perform
1202+
any filesystem queries.
1203+
1204+
To fetch up-to-date information, it's best to call :meth:`Path.is_dir`,
1205+
:meth:`~Path.is_file` and :meth:`~Path.is_symlink` rather than methods of
1206+
this attribute. There is no way to reset the cache; instead you can create
1207+
a new path object with an empty info cache via ``p = Path(p)``.
1208+
1209+
.. versionadded:: 3.14
1210+
1211+
11801212
Reading and writing files
11811213
^^^^^^^^^^^^^^^^^^^^^^^^^
11821214

@@ -1903,3 +1935,56 @@ Below is a table mapping various :mod:`os` functions to their corresponding
19031935
.. [4] :func:`os.walk` always follows symlinks when categorizing paths into
19041936
*dirnames* and *filenames*, whereas :meth:`Path.walk` categorizes all
19051937
symlinks into *filenames* when *follow_symlinks* is false (the default.)
1938+
1939+
1940+
Protocols
1941+
---------
1942+
1943+
.. module:: pathlib.types
1944+
:synopsis: pathlib types for static type checking
1945+
1946+
1947+
The :mod:`pathlib.types` module provides types for static type checking.
1948+
1949+
.. versionadded:: 3.14
1950+
1951+
1952+
.. class:: PathInfo()
1953+
1954+
A :class:`typing.Protocol` describing the
1955+
:attr:`Path.info <pathlib.Path.info>` attribute. Implementations may
1956+
return cached results from their methods.
1957+
1958+
.. method:: exists(*, follow_symlinks=True)
1959+
1960+
Return ``True`` if the path is an existing file or directory, or any
1961+
other kind of file; return ``False`` if the path doesn't exist.
1962+
1963+
If *follow_symlinks* is ``False``, return ``True`` for symlinks without
1964+
checking if their targets exist.
1965+
1966+
.. method:: is_dir(*, follow_symlinks=True)
1967+
1968+
Return ``True`` if the path is a directory, or a symbolic link pointing
1969+
to a directory; return ``False`` if the path is (or points to) any other
1970+
kind of file, or if it doesn't exist.
1971+
1972+
If *follow_symlinks* is ``False``, return ``True`` only if the path
1973+
is a directory (without following symlinks); return ``False`` if the
1974+
path is any other kind of file, or if it doesn't exist.
1975+
1976+
.. method:: is_file(*, follow_symlinks=True)
1977+
1978+
Return ``True`` if the path is a file, or a symbolic link pointing to
1979+
a file; return ``False`` if the path is (or points to) a directory or
1980+
other non-file, or if it doesn't exist.
1981+
1982+
If *follow_symlinks* is ``False``, return ``True`` only if the path
1983+
is a file (without following symlinks); return ``False`` if the path
1984+
is a directory or other other non-file, or if it doesn't exist.
1985+
1986+
.. method:: is_symlink()
1987+
1988+
Return ``True`` if the path is a symbolic link (even if broken); return
1989+
``False`` if the path is a directory or any kind of file, or if it
1990+
doesn't exist.

0 commit comments

Comments
 (0)