Skip to content

Commit 4763a74

Browse files
Merge branch 'main' into warn_explicit-no-module
2 parents bc5981e + 02c1abf commit 4763a74

File tree

91 files changed

+1160
-466
lines changed

Some content is hidden

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

91 files changed

+1160
-466
lines changed

Doc/c-api/iter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ There are two functions specifically for working with iterators.
5454
5555
- ``PYGEN_RETURN`` if iterator returns. Return value is returned via *presult*.
5656
- ``PYGEN_NEXT`` if iterator yields. Yielded value is returned via *presult*.
57-
- ``PYGEN_ERROR`` if iterator has raised and exception. *presult* is set to ``NULL``.
57+
- ``PYGEN_ERROR`` if iterator has raised an exception. *presult* is set to ``NULL``.
5858
5959
.. versionadded:: 3.10

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Pending removal in Python 3.15
9292
Use ``class TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``
9393
to create a TypedDict with zero field.
9494

95-
* The :func:`typing.no_type_check_decorator` decorator function
95+
* The :func:`!typing.no_type_check_decorator` decorator function
9696
has been deprecated since Python 3.13.
9797
After eight years in the :mod:`typing` module,
9898
it has yet to be supported by any major type checker.

Doc/deprecations/pending-removal-in-3.20.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Pending removal in Python 3.20
88
- :mod:`argparse`
99
- :mod:`csv`
1010
- :mod:`!ctypes.macholib`
11+
- :mod:`imaplib`
1112
- :mod:`ipaddress`
1213
- :mod:`json`
1314
- :mod:`logging` (``__date__`` also deprecated)

Doc/faq/general.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ How do I get documentation on Python?
186186
-------------------------------------
187187

188188
The standard documentation for the current stable version of Python is available
189-
at https://docs.python.org/3/. PDF, plain text, and downloadable HTML versions are
189+
at https://docs.python.org/3/. EPUB, plain text, and downloadable HTML versions are
190190
also available at https://docs.python.org/3/download.html.
191191

192192
The documentation is written in reStructuredText and processed by `the Sphinx

Doc/library/annotationlib.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,29 @@ Functions
340340

341341
* VALUE: :attr:`!object.__annotations__` is tried first; if that does not exist,
342342
the :attr:`!object.__annotate__` function is called if it exists.
343+
343344
* FORWARDREF: If :attr:`!object.__annotations__` exists and can be evaluated successfully,
344345
it is used; otherwise, the :attr:`!object.__annotate__` function is called. If it
345346
does not exist either, :attr:`!object.__annotations__` is tried again and any error
346347
from accessing it is re-raised.
348+
349+
* When calling :attr:`!object.__annotate__` it is first called with :attr:`~Format.FORWARDREF`.
350+
If this is not implemented, it will then check if :attr:`~Format.VALUE_WITH_FAKE_GLOBALS`
351+
is supported and use that in the fake globals environment.
352+
If neither of these formats are supported, it will fall back to using :attr:`~Format.VALUE`.
353+
If :attr:`~Format.VALUE` fails, the error from this call will be raised.
354+
347355
* STRING: If :attr:`!object.__annotate__` exists, it is called first;
348356
otherwise, :attr:`!object.__annotations__` is used and stringified
349357
using :func:`annotations_to_string`.
350358

359+
* When calling :attr:`!object.__annotate__` it is first called with :attr:`~Format.STRING`.
360+
If this is not implemented, it will then check if :attr:`~Format.VALUE_WITH_FAKE_GLOBALS`
361+
is supported and use that in the fake globals environment.
362+
If neither of these formats are supported, it will fall back to using :attr:`~Format.VALUE`
363+
with the result converted using :func:`annotations_to_string`.
364+
If :attr:`~Format.VALUE` fails, the error from this call will be raised.
365+
351366
Returns a dict. :func:`!get_annotations` returns a new dict every time
352367
it's called; calling it twice on the same object will return two
353368
different but equivalent dicts.

Doc/library/codecs.rst

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -989,17 +989,22 @@ defined in Unicode. A simple and straightforward way that can store each Unicode
989989
code point, is to store each code point as four consecutive bytes. There are two
990990
possibilities: store the bytes in big endian or in little endian order. These
991991
two encodings are called ``UTF-32-BE`` and ``UTF-32-LE`` respectively. Their
992-
disadvantage is that if e.g. you use ``UTF-32-BE`` on a little endian machine you
993-
will always have to swap bytes on encoding and decoding. ``UTF-32`` avoids this
994-
problem: bytes will always be in natural endianness. When these bytes are read
995-
by a CPU with a different endianness, then bytes have to be swapped though. To
996-
be able to detect the endianness of a ``UTF-16`` or ``UTF-32`` byte sequence,
997-
there's the so called BOM ("Byte Order Mark"). This is the Unicode character
998-
``U+FEFF``. This character can be prepended to every ``UTF-16`` or ``UTF-32``
999-
byte sequence. The byte swapped version of this character (``0xFFFE``) is an
1000-
illegal character that may not appear in a Unicode text. So when the
1001-
first character in a ``UTF-16`` or ``UTF-32`` byte sequence
1002-
appears to be a ``U+FFFE`` the bytes have to be swapped on decoding.
992+
disadvantage is that if, for example, you use ``UTF-32-BE`` on a little endian
993+
machine you will always have to swap bytes on encoding and decoding.
994+
Python's ``UTF-16`` and ``UTF-32`` codecs avoid this problem by using the
995+
platform's native byte order when no BOM is present.
996+
Python follows prevailing platform
997+
practice, so native-endian data round-trips without redundant byte swapping,
998+
even though the Unicode Standard defaults to big-endian when the byte order is
999+
unspecified. When these bytes are read by a CPU with a different endianness,
1000+
the bytes have to be swapped. To be able to detect the endianness of a
1001+
``UTF-16`` or ``UTF-32`` byte sequence, a BOM ("Byte Order Mark") is used.
1002+
This is the Unicode character ``U+FEFF``. This character can be prepended to every
1003+
``UTF-16`` or ``UTF-32`` byte sequence. The byte swapped version of this character
1004+
(``0xFFFE``) is an illegal character that may not appear in a Unicode text.
1005+
When the first character of a ``UTF-16`` or ``UTF-32`` byte sequence is
1006+
``U+FFFE``, the bytes have to be swapped on decoding.
1007+
10031008
Unfortunately the character ``U+FEFF`` had a second purpose as
10041009
a ``ZERO WIDTH NO-BREAK SPACE``: a character that has no width and doesn't allow
10051010
a word to be split. It can e.g. be used to give hints to a ligature algorithm.

Doc/library/functools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ The :mod:`functools` module defines the following functions:
190190

191191
Note, type specificity applies only to the function's immediate arguments
192192
rather than their contents. The scalar arguments, ``Decimal(42)`` and
193-
``Fraction(42)`` are be treated as distinct calls with distinct results.
193+
``Fraction(42)`` are treated as distinct calls with distinct results.
194194
In contrast, the tuple arguments ``('answer', Decimal(42))`` and
195195
``('answer', Fraction(42))`` are treated as equivalent.
196196

Doc/library/glob.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,27 @@
1818
single: - (minus); in glob-style wildcards
1919
single: . (dot); in glob-style wildcards
2020

21-
The :mod:`glob` module finds all the pathnames matching a specified pattern
22-
according to the rules used by the Unix shell, although results are returned in
23-
arbitrary order. No tilde expansion is done, but ``*``, ``?``, and character
21+
The :mod:`!glob` module finds pathnames
22+
using pattern matching rules similar to the Unix shell.
23+
No tilde expansion is done, but ``*``, ``?``, and character
2424
ranges expressed with ``[]`` will be correctly matched. This is done by using
2525
the :func:`os.scandir` and :func:`fnmatch.fnmatch` functions in concert, and
2626
not by actually invoking a subshell.
2727

28-
Note that files beginning with a dot (``.``) can only be matched by
28+
.. note::
29+
The pathnames are returned in no particular order. If you need a specific
30+
order, sort the results.
31+
32+
Files beginning with a dot (``.``) can only be matched by
2933
patterns that also start with a dot,
3034
unlike :func:`fnmatch.fnmatch` or :func:`pathlib.Path.glob`.
31-
(For tilde and shell variable expansion, use :func:`os.path.expanduser` and
32-
:func:`os.path.expandvars`.)
35+
For tilde and shell variable expansion, use :func:`os.path.expanduser` and
36+
:func:`os.path.expandvars`.
3337

3438
For a literal match, wrap the meta-characters in brackets.
3539
For example, ``'[?]'`` matches the character ``'?'``.
3640

37-
The :mod:`glob` module defines the following functions:
41+
The :mod:`!glob` module defines the following functions:
3842

3943

4044
.. function:: glob(pathname, *, root_dir=None, dir_fd=None, recursive=False, \
@@ -51,7 +55,7 @@ The :mod:`glob` module defines the following functions:
5155

5256
If *root_dir* is not ``None``, it should be a :term:`path-like object`
5357
specifying the root directory for searching. It has the same effect on
54-
:func:`glob` as changing the current directory before calling it. If
58+
:func:`!glob` as changing the current directory before calling it. If
5559
*pathname* is relative, the result will contain paths relative to
5660
*root_dir*.
5761

Doc/library/os.rst

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3451,7 +3451,10 @@ features:
34513451

34523452
.. attribute:: stx_mnt_id
34533453

3454-
Mount ID.
3454+
Mount identifier.
3455+
3456+
Equal to ``None`` if :data:`STATX_MNT_ID` is missing from
3457+
:attr:`~os.statx_result.stx_mask`.
34553458

34563459
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
34573460
userspace API headers >= 5.8.
@@ -3460,19 +3463,28 @@ features:
34603463

34613464
Direct I/O memory buffer alignment requirement.
34623465

3466+
Equal to ``None`` if :data:`STATX_DIOALIGN` is missing from
3467+
:attr:`~os.statx_result.stx_mask`.
3468+
34633469
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
34643470
userspace API headers >= 6.1.
34653471

34663472
.. attribute:: stx_dio_offset_align
34673473

34683474
Direct I/O file offset alignment requirement.
34693475

3476+
Equal to ``None`` if :data:`STATX_DIOALIGN` is missing from
3477+
:attr:`~os.statx_result.stx_mask`.
3478+
34703479
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
34713480
userspace API headers >= 6.1.
34723481

34733482
.. attribute:: stx_subvol
34743483

3475-
Subvolume ID.
3484+
Subvolume identifier.
3485+
3486+
Equal to ``None`` if :data:`STATX_SUBVOL` is missing from
3487+
:attr:`~os.statx_result.stx_mask`.
34763488

34773489
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
34783490
userspace API headers >= 6.10.
@@ -3481,34 +3493,49 @@ features:
34813493

34823494
Minimum size for direct I/O with torn-write protection.
34833495

3496+
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3497+
:attr:`~os.statx_result.stx_mask`.
3498+
34843499
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
34853500
userspace API headers >= 6.11.
34863501

34873502
.. attribute:: stx_atomic_write_unit_max
34883503

34893504
Maximum size for direct I/O with torn-write protection.
34903505

3506+
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3507+
:attr:`~os.statx_result.stx_mask`.
3508+
34913509
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
34923510
userspace API headers >= 6.11.
34933511

34943512
.. attribute:: stx_atomic_write_unit_max_opt
34953513

34963514
Maximum optimized size for direct I/O with torn-write protection.
34973515

3516+
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3517+
:attr:`~os.statx_result.stx_mask`.
3518+
34983519
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
34993520
userspace API headers >= 6.16.
35003521

35013522
.. attribute:: stx_atomic_write_segments_max
35023523

35033524
Maximum iovecs for direct I/O with torn-write protection.
35043525

3526+
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3527+
:attr:`~os.statx_result.stx_mask`.
3528+
35053529
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
35063530
userspace API headers >= 6.11.
35073531

35083532
.. attribute:: stx_dio_read_offset_align
35093533

35103534
Direct I/O file offset alignment requirement for reads.
35113535

3536+
Equal to ``None`` if :data:`STATX_DIO_READ_ALIGN` is missing from
3537+
:attr:`~os.statx_result.stx_mask`.
3538+
35123539
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
35133540
userspace API headers >= 6.14.
35143541

@@ -3539,9 +3566,9 @@ features:
35393566
STATX_WRITE_ATOMIC
35403567
STATX_DIO_READ_ALIGN
35413568

3542-
Bitflags for use in the *mask* parameter to :func:`os.statx`. Flags
3543-
including and after :const:`!STATX_MNT_ID` are only available when their
3544-
corresponding members in :class:`statx_result` are available.
3569+
Bitflags for use in the *mask* parameter to :func:`os.statx`. Some of these
3570+
flags may be available even when their corresponding members in
3571+
:class:`statx_result` are not available.
35453572

35463573
.. availability:: Linux >= 4.11 with glibc >= 2.28.
35473574

Doc/library/resource.rst

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ platform.
141141
.. data:: RLIMIT_CPU
142142

143143
The maximum amount of processor time (in seconds) that a process can use. If
144-
this limit is exceeded, a :const:`SIGXCPU` signal is sent to the process. (See
144+
this limit is exceeded, a :const:`~signal.SIGXCPU` signal is sent to the process. (See
145145
the :mod:`signal` module documentation for information about how to catch this
146146
signal and do something useful, e.g. flush open files to disk.)
147147

@@ -363,47 +363,47 @@ These functions are used to retrieve resource usage information:
363363
For backward compatibility, the return value is also accessible as a tuple of 16
364364
elements.
365365

366-
The fields :attr:`ru_utime` and :attr:`ru_stime` of the return value are
366+
The fields :attr:`!ru_utime` and :attr:`!ru_stime` of the return value are
367367
floating-point values representing the amount of time spent executing in user
368368
mode and the amount of time spent executing in system mode, respectively. The
369369
remaining values are integers. Consult the :manpage:`getrusage(2)` man page for
370370
detailed information about these values. A brief summary is presented here:
371371

372-
+--------+---------------------+---------------------------------------+
373-
| Index | Field | Resource |
374-
+========+=====================+=======================================+
375-
| ``0`` | :attr:`ru_utime` | time in user mode (float seconds) |
376-
+--------+---------------------+---------------------------------------+
377-
| ``1`` | :attr:`ru_stime` | time in system mode (float seconds) |
378-
+--------+---------------------+---------------------------------------+
379-
| ``2`` | :attr:`ru_maxrss` | maximum resident set size |
380-
+--------+---------------------+---------------------------------------+
381-
| ``3`` | :attr:`ru_ixrss` | shared memory size |
382-
+--------+---------------------+---------------------------------------+
383-
| ``4`` | :attr:`ru_idrss` | unshared memory size |
384-
+--------+---------------------+---------------------------------------+
385-
| ``5`` | :attr:`ru_isrss` | unshared stack size |
386-
+--------+---------------------+---------------------------------------+
387-
| ``6`` | :attr:`ru_minflt` | page faults not requiring I/O |
388-
+--------+---------------------+---------------------------------------+
389-
| ``7`` | :attr:`ru_majflt` | page faults requiring I/O |
390-
+--------+---------------------+---------------------------------------+
391-
| ``8`` | :attr:`ru_nswap` | number of swap outs |
392-
+--------+---------------------+---------------------------------------+
393-
| ``9`` | :attr:`ru_inblock` | block input operations |
394-
+--------+---------------------+---------------------------------------+
395-
| ``10`` | :attr:`ru_oublock` | block output operations |
396-
+--------+---------------------+---------------------------------------+
397-
| ``11`` | :attr:`ru_msgsnd` | messages sent |
398-
+--------+---------------------+---------------------------------------+
399-
| ``12`` | :attr:`ru_msgrcv` | messages received |
400-
+--------+---------------------+---------------------------------------+
401-
| ``13`` | :attr:`ru_nsignals` | signals received |
402-
+--------+---------------------+---------------------------------------+
403-
| ``14`` | :attr:`ru_nvcsw` | voluntary context switches |
404-
+--------+---------------------+---------------------------------------+
405-
| ``15`` | :attr:`ru_nivcsw` | involuntary context switches |
406-
+--------+---------------------+---------------------------------------+
372+
+--------+----------------------+---------------------------------------+
373+
| Index | Field | Resource |
374+
+========+======================+=======================================+
375+
| ``0`` | :attr:`!ru_utime` | time in user mode (float seconds) |
376+
+--------+----------------------+---------------------------------------+
377+
| ``1`` | :attr:`!ru_stime` | time in system mode (float seconds) |
378+
+--------+----------------------+---------------------------------------+
379+
| ``2`` | :attr:`!ru_maxrss` | maximum resident set size |
380+
+--------+----------------------+---------------------------------------+
381+
| ``3`` | :attr:`!ru_ixrss` | shared memory size |
382+
+--------+----------------------+---------------------------------------+
383+
| ``4`` | :attr:`!ru_idrss` | unshared memory size |
384+
+--------+----------------------+---------------------------------------+
385+
| ``5`` | :attr:`!ru_isrss` | unshared stack size |
386+
+--------+----------------------+---------------------------------------+
387+
| ``6`` | :attr:`!ru_minflt` | page faults not requiring I/O |
388+
+--------+----------------------+---------------------------------------+
389+
| ``7`` | :attr:`!ru_majflt` | page faults requiring I/O |
390+
+--------+----------------------+---------------------------------------+
391+
| ``8`` | :attr:`!ru_nswap` | number of swap outs |
392+
+--------+----------------------+---------------------------------------+
393+
| ``9`` | :attr:`!ru_inblock` | block input operations |
394+
+--------+----------------------+---------------------------------------+
395+
| ``10`` | :attr:`!ru_oublock` | block output operations |
396+
+--------+----------------------+---------------------------------------+
397+
| ``11`` | :attr:`!ru_msgsnd` | messages sent |
398+
+--------+----------------------+---------------------------------------+
399+
| ``12`` | :attr:`!ru_msgrcv` | messages received |
400+
+--------+----------------------+---------------------------------------+
401+
| ``13`` | :attr:`!ru_nsignals` | signals received |
402+
+--------+----------------------+---------------------------------------+
403+
| ``14`` | :attr:`!ru_nvcsw` | voluntary context switches |
404+
+--------+----------------------+---------------------------------------+
405+
| ``15`` | :attr:`!ru_nivcsw` | involuntary context switches |
406+
+--------+----------------------+---------------------------------------+
407407

408408
This function will raise a :exc:`ValueError` if an invalid *who* parameter is
409409
specified. It may also raise :exc:`error` exception in unusual circumstances.

0 commit comments

Comments
 (0)