Skip to content

Commit 558ece4

Browse files
authored
Merge branch 'main' into gh-149504
2 parents ea34446 + e667d62 commit 558ece4

52 files changed

Lines changed: 523 additions & 308 deletions

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

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

Lines changed: 1 addition & 1 deletion
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

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

Doc/library/mimetypes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,18 @@ behavior of the module.
129129
Add a mapping from the MIME type *type* to the extension *ext*. When the
130130
extension is already known, the new type will replace the old one. When the type
131131
is already known the extension will be added to the list of known extensions.
132+
Valid extensions are empty or start with a ``'.'``.
132133

133134
When *strict* is ``True`` (the default), the mapping will be added to the
134135
official MIME types, otherwise to the non-standard ones.
135136

137+
.. deprecated:: 3.14
138+
*ext* values that do not start with ``'.'`` are deprecated.
139+
140+
.. versionchanged:: next
141+
*ext* now must start with ``'.'``. Otherwise :exc:`ValueError` is raised.
142+
143+
136144

137145
.. data:: inited
138146

Doc/library/pickle.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The :mod:`!pickle` module differs from :mod:`marshal` in several significant way
5656
* :mod:`marshal` cannot be used to serialize user-defined classes and their
5757
instances. :mod:`!pickle` can save and restore class instances transparently,
5858
however the class definition must be importable and live in the same module as
59-
when the object was stored.
59+
when the object was pickled.
6060

6161
* The :mod:`marshal` serialization format is not guaranteed to be portable
6262
across Python versions. Because its primary job in life is to support
@@ -693,7 +693,10 @@ or both.
693693
If a string is returned, the string should be interpreted as the name of a
694694
global variable. It should be the object's local name relative to its
695695
module; the pickle module searches the module namespace to determine the
696-
object's module. This behaviour is typically useful for singletons.
696+
object's module: for a given ``obj`` to be pickled, the ``__module__``
697+
attribute is looked up on ``obj`` directly, which falls back to a lookup
698+
on the type of ``obj`` if no ``__module__`` instance attribute is set.
699+
This behaviour is typically useful for singletons.
697700

698701
When a tuple is returned, it must be between two and six items long.
699702
Optional items can either be omitted, or ``None`` can be provided as their

Doc/library/sys.rst

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only
879879

880880
.. versionchanged:: 3.6
881881
Windows is no longer guaranteed to return ``'mbcs'``. See :pep:`529`
882-
and :func:`_enablelegacywindowsfsencoding` for more information.
882+
for more information.
883883

884884
.. versionchanged:: 3.7
885885
Return ``'utf-8'`` if the :ref:`Python UTF-8 Mode <utf8-mode>` is
@@ -2107,31 +2107,6 @@ always available. Unless explicitly noted otherwise, all variables are read-only
21072107
See :pep:`768` for more details.
21082108

21092109

2110-
.. function:: _enablelegacywindowsfsencoding()
2111-
2112-
Changes the :term:`filesystem encoding and error handler` to 'mbcs' and
2113-
'replace' respectively, for consistency with versions of Python prior to
2114-
3.6.
2115-
2116-
This is equivalent to defining the :envvar:`PYTHONLEGACYWINDOWSFSENCODING`
2117-
environment variable before launching Python.
2118-
2119-
See also :func:`sys.getfilesystemencoding` and
2120-
:func:`sys.getfilesystemencodeerrors`.
2121-
2122-
.. availability:: Windows.
2123-
2124-
.. note::
2125-
Changing the filesystem encoding after Python startup is risky because
2126-
the old fsencoding or paths encoded by the old fsencoding may be cached
2127-
somewhere. Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead.
2128-
2129-
.. versionadded:: 3.6
2130-
See :pep:`529` for more details.
2131-
2132-
.. deprecated-removed:: 3.13 3.16
2133-
Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead.
2134-
21352110
.. data:: stdin
21362111
stdout
21372112
stderr

Doc/tools/removed-ids.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ c-api/file.html: deprecated-api
77
library/asyncio-task.html: terminating-a-task-group
88

99
# Removed APIs
10-
library/symtable.html: symtable.Class.get_methods
10+
library/symtable.html: symtable.Class.get_methods
11+
library/sys.html: sys._enablelegacywindowsfsencoding

Doc/using/cmdline.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,9 +1154,6 @@ conflict.
11541154
'replace', respectively. Otherwise, the new defaults 'utf-8' and
11551155
'surrogatepass' are used.
11561156

1157-
This may also be enabled at runtime with
1158-
:func:`sys._enablelegacywindowsfsencoding`.
1159-
11601157
.. availability:: Windows.
11611158

11621159
.. versionadded:: 3.6

Doc/whatsnew/3.13.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ New Deprecations
19581958

19591959
* :mod:`sys`:
19601960

1961-
* Deprecate the :func:`~sys._enablelegacywindowsfsencoding` function,
1961+
* Deprecate the :func:`!_enablelegacywindowsfsencoding` function,
19621962
to be removed in Python 3.16.
19631963
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
19641964
(Contributed by Inada Naoki in :gh:`73427`.)

0 commit comments

Comments
 (0)