Skip to content

Commit cead014

Browse files
authored
Merge branch 'main' into minidom
2 parents eb5f12f + 14af19e commit cead014

301 files changed

Lines changed: 4386 additions & 23329 deletions

File tree

Some content is hidden

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

.github/CODEOWNERS

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,10 @@ Lib/test/test_string/test_templatelib.py @lysnikolaou @AA-Turner
586586
**/*sysconfig* @FFY00
587587

588588
# SQLite 3
589-
Doc/library/sqlite3.rst @berkerpeksag @erlend-aasland
590-
Lib/sqlite3/ @berkerpeksag @erlend-aasland
591-
Lib/test/test_sqlite3/ @berkerpeksag @erlend-aasland
592-
Modules/_sqlite/ @berkerpeksag @erlend-aasland
589+
Doc/library/sqlite3.rst @erlend-aasland
590+
Lib/sqlite3/ @erlend-aasland
591+
Lib/test/test_sqlite3/ @erlend-aasland
592+
Modules/_sqlite/ @erlend-aasland
593593

594594
# Subprocess
595595
Lib/subprocess.py @gpshead
@@ -622,9 +622,6 @@ Modules/_typesmodule.c @AA-Turner
622622
Lib/unittest/mock.py @cjw296
623623
Lib/test/test_unittest/testmock/ @cjw296
624624

625-
# Urllib
626-
**/*robotparser* @berkerpeksag
627-
628625
# Venv
629626
**/*venv* @vsajip @FFY00
630627

.github/workflows/mypy.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,11 @@ jobs:
6969
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7070
with:
7171
persist-credentials: false
72-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
72+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
7373
with:
7474
python-version: "3.15"
75-
allow-prereleases: true
76-
cache: pip
77-
cache-dependency-path: Tools/requirements-dev.txt
78-
- run: pip install -r Tools/requirements-dev.txt
75+
activate-environment: true
76+
cache-dependency-glob: Tools/requirements-dev.txt
77+
- run: uv pip install -r Tools/requirements-dev.txt
7978
- run: python3 Misc/mypy/make_symlinks.py --symlink
80-
- run: mypy --config-file ${{ matrix.target }}/mypy.ini
79+
- run: mypy --num-workers 4 --config-file ${{ matrix.target }}/mypy.ini

.github/workflows/posix-deps-apt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ apt-get -yq --no-install-recommends install \
2727
zlib1g-dev
2828

2929
# Workaround missing libmpdec-dev on ubuntu 24.04 by building mpdecimal
30-
# from source. ppa:ondrej/php (launchpad.net) are unreliable
30+
# from source. ppa:ondrej/php (launchpad.net) are unreliable
3131
# (https://status.canonical.com) so fetch the tarball directly
3232
# from the upstream host.
3333
# https://www.bytereef.org/mpdecimal/

.github/workflows/reusable-macos.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ jobs:
3838
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
3939
- name: Install Homebrew dependencies
4040
run: |
41-
brew install pkg-config openssl@3.5 xz gdbm tcl-tk@9 make
42-
# Because alternate versions are not symlinked into place by default:
43-
brew link --overwrite tcl-tk@9
41+
brew bundle --file=Misc/Brewfile
42+
brew install make
4443
- name: Configure CPython
4544
run: |
4645
MACOSX_DEPLOYMENT_TARGET=10.15 \

Doc/c-api/sentinel.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,20 @@ Sentinel objects
1414

1515
.. c:function:: int PySentinel_Check(PyObject *o)
1616
17-
Return true if *o* is a :class:`sentinel` object. The :class:`sentinel` type
18-
does not allow subclasses, so this check is exact.
17+
Return true if *o* is a :class:`sentinel` object or a subtype.
18+
The :class:`sentinel` type does not currently allow subclasses,
19+
so this check is exact.
20+
Future Python versions may choose to allow subtyping.
21+
This function always succeeds.
22+
23+
.. versionadded:: 3.15
24+
25+
.. c:function:: int PySentinel_CheckExact(PyObject *o)
26+
27+
Return true if *o* is a :class:`sentinel` object, but not a subtype.
28+
The :class:`sentinel` type does not currently allow subclasses.
29+
Future Python versions may choose to allow subtyping.
30+
This function always succeeds.
1931
2032
.. versionadded:: 3.15
2133

Doc/c-api/stable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ versions of Python.
114114

115115
All functions in Stable ABI are present as functions in Python's shared
116116
library, not solely as macros.
117-
This makes them usable are usable from languages that don't use the C
117+
This makes them usable in languages that don't use the C
118118
preprocessor, including Python's :py:mod:`ctypes`.
119119

120120

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Pending removal in Python 3.16
8989

9090
* :mod:`sys`:
9191

92-
* The :func:`~sys._enablelegacywindowsfsencoding` function
92+
* The :func:`!_enablelegacywindowsfsencoding` function
9393
has been deprecated since Python 3.13.
9494
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
9595

@@ -101,5 +101,5 @@ Pending removal in Python 3.16
101101

102102
* :mod:`tarfile`:
103103

104-
* The undocumented and unused :attr:`!TarFile.tarfile` attribute
104+
* The undocumented and unused :attr:`!TarInfo.tarfile` attribute
105105
has been deprecated since Python 3.13.

Doc/library/array.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This module defines an object type which can compactly represent an array of
1212
basic values: characters, integers, floating-point numbers, complex numbers. Arrays are mutable :term:`sequence`
1313
types and behave very much like lists, except that the type of objects stored in
1414
them is constrained. The type is specified at object creation time by using a
15-
:dfn:`type code`, which is a single character. The following type codes are
15+
:dfn:`type code`. The following type codes are
1616
defined:
1717

1818
+-----------+--------------------+-------------------+-----------------------+-------+
@@ -91,7 +91,7 @@ Notes:
9191
.. seealso::
9292

9393
The :ref:`ctypes <ctypes-fundamental-data-types>` and
94-
:ref:`struct <format-characters>` modules,
94+
:ref:`struct <type-codes>` modules,
9595
as well as third-party modules like `numpy <https://numpy.org/doc/stable/reference/arrays.interface.html#object.__array_interface__>`__,
9696
use similar -- but slightly different -- type codes.
9797

Doc/library/base64.rst

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
This module provides functions for encoding binary data to printable
1717
ASCII characters and decoding such encodings back to binary data.
1818
This includes the :ref:`encodings specified in <base64-rfc-4648>`
19-
:rfc:`4648` (Base64, Base32 and Base16)
20-
and the non-standard :ref:`Base85 encodings <base64-base-85>`.
19+
:rfc:`4648` (Base64, Base32 and Base16), the :ref:`Base85 encoding
20+
<base64-base-85>` specified in `PDF 2.0
21+
<https://pdfa.org/resource/iso-32000-2/>`_, and non-standard variants
22+
of Base85 used elsewhere.
2123

2224
There are two interfaces provided by this module. The modern interface
2325
supports encoding :term:`bytes-like objects <bytes-like object>` to ASCII
@@ -284,19 +286,28 @@ POST request.
284286
Base85 Encodings
285287
-----------------
286288

287-
Base85 encoding is not formally specified but rather a de facto standard,
288-
thus different systems perform the encoding differently.
289+
Base85 encoding is a family of algorithms which represent four bytes
290+
using five ASCII characters. Originally implemented in the Unix
291+
``btoa(1)`` utility, a version of it was later adopted by Adobe in the
292+
PostScript language and is standardized in PDF 2.0 (ISO 32000-2).
293+
This version, in both its ``btoa`` and PDF variants, is implemented by
294+
:func:`a85encode`.
289295

290-
The :func:`a85encode` and :func:`b85encode` functions in this module are two implementations of
291-
the de facto standard. You should call the function with the Base85
292-
implementation used by the software you intend to work with.
296+
A separate version, using a different output character set, was
297+
defined as an April Fool's joke in :rfc:`1924` but is now used by Git
298+
and other software. This version is implemented by :func:`b85encode`.
293299

294-
The two functions present in this module differ in how they handle the following:
300+
Finally, a third version, using yet another output character set
301+
designed for safe inclusion in programming language strings, is
302+
defined by ZeroMQ and implemented here by :func:`z85encode`.
295303

296-
* Whether to include enclosing ``<~`` and ``~>`` markers
297-
* Whether to include newline characters
298-
* The set of ASCII characters used for encoding
299-
* Handling of null bytes
304+
The functions present in this module differ in how they handle the following:
305+
306+
* Whether to include and expect enclosing ``<~`` and ``~>`` markers.
307+
* Whether to fold the input into multiple lines.
308+
* The set of ASCII characters used for encoding.
309+
* Compact encodings of sequences of spaces and null bytes.
310+
* The encoding of zero-padding bytes applied to the input.
300311

301312
Refer to the documentation of the individual functions for more information.
302313

@@ -307,18 +318,22 @@ Refer to the documentation of the individual functions for more information.
307318

308319
*foldspaces* is an optional flag that uses the special short sequence 'y'
309320
instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This
310-
feature is not supported by the "standard" Ascii85 encoding.
321+
feature is not supported by the standard encoding used in PDF.
311322

312323
If *wrapcol* is non-zero, insert a newline (``b'\n'``) character
313324
after at most every *wrapcol* characters.
314325
If *wrapcol* is zero (default), do not insert any newlines.
315326

316-
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
317-
multiple of 4 bytes before encoding.
318-
Note that the ``btoa`` implementation always pads.
327+
*pad* controls whether zero-padding applied to the end of the input
328+
is fully retained in the output encoding, as done by ``btoa``,
329+
producing an exact multiple of 5 bytes of output. This is not part
330+
of the standard encoding used in PDF, as it does not preserve the
331+
length of the data.
319332

320-
*adobe* controls whether the encoded byte sequence is framed with ``<~``
321-
and ``~>``, which is used by the Adobe implementation.
333+
*adobe* controls whether the encoded byte sequence is framed with
334+
``<~`` and ``~>``, as in a PostScript base-85 string literal. Note
335+
that while ASCII85Decode streams in PDF documents *must* be
336+
terminated with ``~>``, they *must not* use a leading ``<~``.
322337

323338
.. versionadded:: 3.4
324339

@@ -330,10 +345,12 @@ Refer to the documentation of the individual functions for more information.
330345

331346
*foldspaces* is a flag that specifies whether the 'y' short sequence
332347
should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20).
333-
This feature is not supported by the "standard" Ascii85 encoding.
348+
This feature is not supported by the standard Ascii85 encoding used in
349+
PDF and PostScript.
334350

335-
*adobe* controls whether the input sequence is in Adobe Ascii85 format
336-
(i.e. is framed with <~ and ~>).
351+
*adobe* controls whether the ``<~`` and ``~>`` markers are
352+
present. While the leading ``<~`` is not required, the input must
353+
end with ``~>``, or a :exc:`ValueError` is raised.
337354

338355
*ignorechars* should be a :term:`bytes-like object` containing characters
339356
to ignore from the input.
@@ -356,8 +373,11 @@ Refer to the documentation of the individual functions for more information.
356373
Encode the :term:`bytes-like object` *b* using base85 (as used in e.g.
357374
git-style binary diffs) and return the encoded :class:`bytes`.
358375

359-
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
360-
multiple of 4 bytes before encoding.
376+
The input is padded with ``b'\0'`` so its length is a multiple of 4
377+
bytes before encoding. If *pad* is true, all the resulting
378+
characters are retained in the output, which will always be a
379+
multiple of 5 bytes, and thus the length of the data may not be
380+
preserved on decoding.
361381

362382
If *wrapcol* is non-zero, insert a newline (``b'\n'``) character
363383
after at most every *wrapcol* characters.
@@ -372,8 +392,7 @@ Refer to the documentation of the individual functions for more information.
372392
.. function:: b85decode(b, *, ignorechars=b'', canonical=False)
373393

374394
Decode the base85-encoded :term:`bytes-like object` or ASCII string *b* and
375-
return the decoded :class:`bytes`. Padding is implicitly removed, if
376-
necessary.
395+
return the decoded :class:`bytes`.
377396

378397
*ignorechars* should be a :term:`bytes-like object` containing characters
379398
to ignore from the input.
@@ -392,11 +411,12 @@ Refer to the documentation of the individual functions for more information.
392411
.. function:: z85encode(s, pad=False, *, wrapcol=0)
393412

394413
Encode the :term:`bytes-like object` *s* using Z85 (as used in ZeroMQ)
395-
and return the encoded :class:`bytes`. See `Z85 specification
396-
<https://rfc.zeromq.org/spec/32/>`_ for more information.
414+
and return the encoded :class:`bytes`.
397415

398-
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
399-
multiple of 4 bytes before encoding.
416+
The input is padded with ``b'\0'`` so its length is a multiple of 4
417+
bytes before encoding. If *pad* is true, all the resulting
418+
characters are retained in the output, which will always be a
419+
multiple of 5 bytes, as required by the ZeroMQ standard.
400420

401421
If *wrapcol* is non-zero, insert a newline (``b'\n'``) character
402422
after at most every *wrapcol* characters.
@@ -414,8 +434,7 @@ Refer to the documentation of the individual functions for more information.
414434
.. function:: z85decode(s, *, ignorechars=b'', canonical=False)
415435

416436
Decode the Z85-encoded :term:`bytes-like object` or ASCII string *s* and
417-
return the decoded :class:`bytes`. See `Z85 specification
418-
<https://rfc.zeromq.org/spec/32/>`_ for more information.
437+
return the decoded :class:`bytes`.
419438

420439
*ignorechars* should be a :term:`bytes-like object` containing characters
421440
to ignore from the input.
@@ -499,3 +518,11 @@ recommended to review the security section for any code deployed to production.
499518
Section 5.2, "Base64 Content-Transfer-Encoding," provides the definition of the
500519
base64 encoding.
501520

521+
`ISO 32000-2 Portable document format - Part 2: PDF 2.0 <https://pdfa.org/resource/iso-32000-2/>`_
522+
Section 7.4.3, "ASCII85Decode Filter," provides the definition
523+
of the Ascii85 encoding used in PDF and PostScript, including
524+
the output character set and the details of data length preservation
525+
using zero-padding and partial output groups.
526+
527+
`ZeroMQ RFC 32/Z85 <https://rfc.zeromq.org/spec/32/>`_
528+
The "Formal Specification" section provides the character set used in Z85.

Doc/library/binascii.rst

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ The :mod:`!binascii` module defines the following functions:
133133
should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20).
134134
This feature is not supported by the "standard" Ascii85 encoding.
135135

136-
*adobe* controls whether the input sequence is in Adobe Ascii85 format
137-
(i.e. is framed with <~ and ~>).
136+
*adobe* controls whether the encoded byte sequence is framed with
137+
``<~`` and ``~>``, as in a PostScript base-85 string literal. If
138+
*adobe* is true, a leading ``<~`` is optionally accepted, while a
139+
trailing ``~>`` is *required*, and :exc:`binascii.Error` is raised
140+
if it is not found.
138141

139142
*ignorechars* should be a :term:`bytes-like object` containing characters
140143
to ignore from the input.
@@ -164,12 +167,16 @@ The :mod:`!binascii` module defines the following functions:
164167
after at most every *wrapcol* characters.
165168
If *wrapcol* is zero (default), do not insert any newlines.
166169

167-
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
168-
multiple of 4 bytes before encoding.
169-
Note that the ``btoa`` implementation always pads.
170+
If *pad* is true, the zero-padding applied to the end of the input
171+
is fully retained in the output encoding, as done by ``btoa``,
172+
producing an exact multiple of 5 bytes of output. This is not part
173+
of the standard encoding used in PDF, as it does not preserve the
174+
length of the data.
170175

171-
*adobe* controls whether the encoded byte sequence is framed with ``<~``
172-
and ``~>``, which is used by the Adobe implementation.
176+
*adobe* controls whether the encoded byte sequence is framed with
177+
``<~`` and ``~>``, as in a PostScript base-85 string literal. Note
178+
that while ASCII85Decode streams in PDF documents *must* be
179+
terminated with ``~>``, they *must not* use a leading ``<~``.
173180

174181
.. versionadded:: 3.15
175182

@@ -213,8 +220,10 @@ The :mod:`!binascii` module defines the following functions:
213220
after at most every *wrapcol* characters.
214221
If *wrapcol* is zero (default), do not insert any newlines.
215222

216-
If *pad* is true, the input is padded with ``b'\0'`` so its length is a
217-
multiple of 4 bytes before encoding.
223+
If *pad* is true, the zero-padding applied to the end of the input
224+
is retained in the output, which will always be a multiple of 5
225+
bytes, and thus the length of the data may not be preserved on
226+
decoding.
218227

219228
.. versionadded:: 3.15
220229

0 commit comments

Comments
 (0)