Skip to content

Commit dbebb28

Browse files
authored
Merge branch 'main' into decimal-version
2 parents 56a75e0 + 99c3c63 commit dbebb28

39 files changed

+225
-131
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.20.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Pending removal in Python 3.20
99
- :mod:`csv`
1010
- :mod:`!ctypes.macholib`
1111
- :mod:`decimal` (Use :data:`decimal.SPEC_VERSION` instead)
12+
- :mod:`imaplib`
1213
- :mod:`ipaddress`
1314
- :mod:`json`
1415
- :mod:`logging` (``__date__`` also deprecated)

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

Doc/library/signal.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@ The variables defined in the :mod:`signal` module are:
265265

266266
.. availability:: Unix.
267267

268+
.. data:: SIGXCPU
269+
270+
CPU time limit exceeded.
271+
272+
.. availability:: Unix.
273+
268274
.. data:: SIG*
269275

270276
All the signal numbers are defined symbolically. For example, the hangup signal

Doc/library/tkinter.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,7 @@ geometry
839839
For example: ``fred["geometry"] = "200x100"``.
840840

841841
justify
842-
Legal values are the strings: ``"left"``, ``"center"``, ``"right"``, and
843-
``"fill"``.
842+
Legal values are the strings: ``"left"``, ``"center"``, and ``"right"``.
844843

845844
region
846845
This is a string with four space-delimited elements, each of which is a legal

Doc/library/warnings.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,14 +480,21 @@ Available Functions
480480
.. function:: warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None, source=None)
481481

482482
This is a low-level interface to the functionality of :func:`warn`, passing in
483-
explicitly the message, category, filename and line number, and optionally the
484-
module name and the registry (which should be the ``__warningregistry__``
485-
dictionary of the module). The module name defaults to the filename with
486-
``.py`` stripped; if no registry is passed, the warning is never suppressed.
483+
explicitly the message, category, filename and line number, and optionally
484+
other arguments.
487485
*message* must be a string and *category* a subclass of :exc:`Warning` or
488486
*message* may be a :exc:`Warning` instance, in which case *category* will be
489487
ignored.
490488

489+
*module*, if supplied, should be the module name.
490+
If no module is passed, the filename with ``.py`` stripped is used.
491+
492+
*registry*, if supplied, should be the ``__warningregistry__`` dictionary
493+
of the module.
494+
If no registry is passed, each warning is treated as the first occurrence,
495+
that is, filter actions ``"default"``, ``"module"`` and ``"once"`` are
496+
handled as ``"always"``.
497+
491498
*module_globals*, if supplied, should be the global namespace in use by the code
492499
for which the warning is issued. (This argument is used to support displaying
493500
source for modules found in zipfiles or other non-filesystem import

Doc/library/zlib.rst

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,20 @@ The available exception and functions in this module are:
5656

5757
.. versionadded:: 3.15
5858

59-
.. function:: compress(data, /, level=-1, wbits=MAX_WBITS)
59+
.. function:: compress(data, /, level=Z_DEFAULT_COMPRESSION, wbits=MAX_WBITS)
6060

6161
Compresses the bytes in *data*, returning a bytes object containing compressed data.
6262
*level* is an integer from ``0`` to ``9`` or ``-1`` controlling the level of compression;
63-
``1`` (Z_BEST_SPEED) is fastest and produces the least compression, ``9`` (Z_BEST_COMPRESSION)
64-
is slowest and produces the most. ``0`` (Z_NO_COMPRESSION) is no compression.
65-
The default value is ``-1`` (Z_DEFAULT_COMPRESSION). Z_DEFAULT_COMPRESSION represents a default
66-
compromise between speed and compression (currently equivalent to level 6).
63+
See :const:`Z_BEST_SPEED` (``1``), :const:`Z_BEST_COMPRESSION` (``9``),
64+
:const:`Z_NO_COMPRESSION` (``0``), and the default,
65+
:const:`Z_DEFAULT_COMPRESSION` (``-1``) for more information about these values.
6766

6867
.. _compress-wbits:
6968

7069
The *wbits* argument controls the size of the history buffer (or the
7170
"window size") used when compressing data, and whether a header and
7271
trailer is included in the output. It can take several ranges of values,
73-
defaulting to ``15`` (MAX_WBITS):
72+
defaulting to ``15`` (:const:`MAX_WBITS`):
7473

7574
* +9 to +15: The base-two logarithm of the window size, which
7675
therefore ranges between 512 and 32768. Larger values produce
@@ -94,17 +93,15 @@ The available exception and functions in this module are:
9493
The *wbits* parameter is now available to set window bits and
9594
compression type.
9695

97-
.. function:: compressobj(level=-1, method=DEFLATED, wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL, strategy=Z_DEFAULT_STRATEGY[, zdict])
96+
.. function:: compressobj(level=Z_DEFAULT_COMPRESSION, method=DEFLATED, wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL, strategy=Z_DEFAULT_STRATEGY[, zdict])
9897

9998
Returns a compression object, to be used for compressing data streams that won't
10099
fit into memory at once.
101100

102101
*level* is the compression level -- an integer from ``0`` to ``9`` or ``-1``.
103-
A value of ``1`` (Z_BEST_SPEED) is fastest and produces the least compression,
104-
while a value of ``9`` (Z_BEST_COMPRESSION) is slowest and produces the most.
105-
``0`` (Z_NO_COMPRESSION) is no compression. The default value is ``-1`` (Z_DEFAULT_COMPRESSION).
106-
Z_DEFAULT_COMPRESSION represents a default compromise between speed and compression
107-
(currently equivalent to level 6).
102+
See :const:`Z_BEST_SPEED` (``1``), :const:`Z_BEST_COMPRESSION` (``9``),
103+
:const:`Z_NO_COMPRESSION` (``0``), and the default,
104+
:const:`Z_DEFAULT_COMPRESSION` (``-1``) for more information about these values.
108105

109106
*method* is the compression algorithm. Currently, the only supported value is
110107
:const:`DEFLATED`.
@@ -119,7 +116,7 @@ The available exception and functions in this module are:
119116

120117
*strategy* is used to tune the compression algorithm. Possible values are
121118
:const:`Z_DEFAULT_STRATEGY`, :const:`Z_FILTERED`, :const:`Z_HUFFMAN_ONLY`,
122-
:const:`Z_RLE` (zlib 1.2.0.1) and :const:`Z_FIXED` (zlib 1.2.2.2).
119+
:const:`Z_RLE` and :const:`Z_FIXED`.
123120

124121
*zdict* is a predefined compression dictionary. This is a sequence of bytes
125122
(such as a :class:`bytes` object) containing subsequences that are expected
@@ -247,7 +244,7 @@ Compression objects support the following methods:
247244
All pending input is processed, and a bytes object containing the remaining compressed
248245
output is returned. *mode* can be selected from the constants
249246
:const:`Z_NO_FLUSH`, :const:`Z_PARTIAL_FLUSH`, :const:`Z_SYNC_FLUSH`,
250-
:const:`Z_FULL_FLUSH`, :const:`Z_BLOCK` (zlib 1.2.3.4), or :const:`Z_FINISH`,
247+
:const:`Z_FULL_FLUSH`, :const:`Z_BLOCK`, or :const:`Z_FINISH`,
251248
defaulting to :const:`Z_FINISH`. Except :const:`Z_FINISH`, all constants
252249
allow compressing further bytestrings of data, while :const:`Z_FINISH` finishes the
253250
compressed stream and prevents compressing any more data. After calling :meth:`flush`
@@ -365,24 +362,25 @@ behavior:
365362

366363
.. data:: Z_NO_COMPRESSION
367364

368-
Compression level ``0``.
365+
Compression level ``0``; no compression.
369366

370367
.. versionadded:: 3.6
371368

372369

373370
.. data:: Z_BEST_SPEED
374371

375-
Compression level ``1``.
372+
Compression level ``1``; fastest and produces the least compression.
376373

377374

378375
.. data:: Z_BEST_COMPRESSION
379376

380-
Compression level ``9``.
377+
Compression level ``9``; slowest and produces the most compression.
381378

382379

383380
.. data:: Z_DEFAULT_COMPRESSION
384381

385-
Default compression level (``-1``).
382+
Default compression level (``-1``); a compromise between speed and
383+
compression. Currently equivalent to compression level ``6``.
386384

387385

388386
.. data:: Z_DEFAULT_STRATEGY

0 commit comments

Comments
 (0)