Skip to content

Commit 04a9b14

Browse files
authored
Merge branch 'main' into fix-issue-134209
2 parents 82c9b1c + e3dda8f commit 04a9b14

File tree

13 files changed

+185
-148
lines changed

13 files changed

+185
-148
lines changed

Doc/library/base64.rst

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,17 @@
1515

1616
This module provides functions for encoding binary data to printable
1717
ASCII characters and decoding such encodings back to binary data.
18-
It provides encoding and decoding functions for the encodings specified in
19-
:rfc:`4648`, which defines the Base16, Base32, and Base64 algorithms,
20-
and for the de-facto standard Ascii85 and Base85 encodings.
21-
22-
The :rfc:`4648` encodings are suitable for encoding binary data so that it can be
23-
safely sent by email, used as parts of URLs, or included as part of an HTTP
24-
POST request. The encoding algorithm is not the same as the
25-
:program:`uuencode` program.
18+
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>`.
2621

2722
There are two interfaces provided by this module. The modern interface
2823
supports encoding :term:`bytes-like objects <bytes-like object>` to ASCII
2924
:class:`bytes`, and decoding :term:`bytes-like objects <bytes-like object>` or
3025
strings containing ASCII to :class:`bytes`. Both base-64 alphabets
3126
defined in :rfc:`4648` (normal, and URL- and filesystem-safe) are supported.
3227

33-
The legacy interface does not support decoding from strings, but it does
28+
The :ref:`legacy interface <base64-legacy>` does not support decoding from strings, but it does
3429
provide functions for encoding and decoding to and from :term:`file objects
3530
<file object>`. It only supports the Base64 standard alphabet, and it adds
3631
newlines every 76 characters as per :rfc:`2045`. Note that if you are looking
@@ -46,7 +41,15 @@ package instead.
4641
Any :term:`bytes-like objects <bytes-like object>` are now accepted by all
4742
encoding and decoding functions in this module. Ascii85/Base85 support added.
4843

49-
The modern interface provides:
44+
45+
.. _base64-rfc-4648:
46+
47+
RFC 4648 Encodings
48+
------------------
49+
50+
The :rfc:`4648` encodings are suitable for encoding binary data so that it can be
51+
safely sent by email, used as parts of URLs, or included as part of an HTTP
52+
POST request.
5053

5154
.. function:: b64encode(s, altchars=None)
5255

@@ -181,6 +184,26 @@ The modern interface provides:
181184
incorrectly padded or if there are non-alphabet characters present in the
182185
input.
183186

187+
.. _base64-base-85:
188+
189+
Base85 Encodings
190+
-----------------
191+
192+
Base85 encoding is not formally specified but rather a de facto standard,
193+
thus different systems perform the encoding differently.
194+
195+
The :func:`a85encode` and :func:`b85encode` functions in this module are two implementations of
196+
the de facto standard. You should call the function with the Base85
197+
implementation used by the software you intend to work with.
198+
199+
The two functions present in this module differ in how they handle the following:
200+
201+
* Whether to include enclosing ``<~`` and ``~>`` markers
202+
* Whether to include newline characters
203+
* The set of ASCII characters used for encoding
204+
* Handling of null bytes
205+
206+
Refer to the documentation of the individual functions for more information.
184207

185208
.. function:: a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False)
186209

@@ -262,7 +285,10 @@ The modern interface provides:
262285
.. versionadded:: 3.13
263286

264287

265-
The legacy interface:
288+
.. _base64-legacy:
289+
290+
Legacy Interface
291+
----------------
266292

267293
.. function:: decode(input, output)
268294

Include/internal/pycore_uop_ids.h

Lines changed: 42 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/pythoninfo.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,16 @@ def collect_zlib(info_add):
658658
copy_attributes(info_add, zlib, 'zlib.%s', attributes)
659659

660660

661+
def collect_zstd(info_add):
662+
try:
663+
import _zstd
664+
except ImportError:
665+
return
666+
667+
attributes = ('zstd_version',)
668+
copy_attributes(info_add, _zstd, 'zstd.%s', attributes)
669+
670+
661671
def collect_expat(info_add):
662672
try:
663673
from xml.parsers import expat
@@ -1051,6 +1061,7 @@ def collect_info(info):
10511061
collect_tkinter,
10521062
collect_windows,
10531063
collect_zlib,
1064+
collect_zstd,
10541065
collect_libregrtest_utils,
10551066

10561067
# Collecting from tests should be last as they have side effects.

Lib/test/test_capi/test_opt.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,9 +1955,10 @@ def testfunc(n):
19551955
self.assertEqual(res, TIER2_THRESHOLD)
19561956
self.assertIsNotNone(ex)
19571957
uops = get_opnames(ex)
1958-
self.assertIn("_CALL_ISINSTANCE", uops)
1958+
self.assertNotIn("_CALL_ISINSTANCE", uops)
19591959
self.assertNotIn("_GUARD_THIRD_NULL", uops)
19601960
self.assertNotIn("_GUARD_CALLABLE_ISINSTANCE", uops)
1961+
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
19611962

19621963
def test_call_list_append(self):
19631964
def testfunc(n):
@@ -1987,9 +1988,10 @@ def testfunc(n):
19871988
self.assertEqual(res, TIER2_THRESHOLD)
19881989
self.assertIsNotNone(ex)
19891990
uops = get_opnames(ex)
1990-
self.assertIn("_CALL_ISINSTANCE", uops)
1991+
self.assertNotIn("_CALL_ISINSTANCE", uops)
19911992
self.assertNotIn("_TO_BOOL_BOOL", uops)
19921993
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)
1994+
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
19931995

19941996
def test_call_isinstance_is_false(self):
19951997
def testfunc(n):
@@ -2004,9 +2006,10 @@ def testfunc(n):
20042006
self.assertEqual(res, TIER2_THRESHOLD)
20052007
self.assertIsNotNone(ex)
20062008
uops = get_opnames(ex)
2007-
self.assertIn("_CALL_ISINSTANCE", uops)
2009+
self.assertNotIn("_CALL_ISINSTANCE", uops)
20082010
self.assertNotIn("_TO_BOOL_BOOL", uops)
20092011
self.assertNotIn("_GUARD_IS_FALSE_POP", uops)
2012+
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
20102013

20112014
def test_call_isinstance_subclass(self):
20122015
def testfunc(n):
@@ -2021,9 +2024,10 @@ def testfunc(n):
20212024
self.assertEqual(res, TIER2_THRESHOLD)
20222025
self.assertIsNotNone(ex)
20232026
uops = get_opnames(ex)
2024-
self.assertIn("_CALL_ISINSTANCE", uops)
2027+
self.assertNotIn("_CALL_ISINSTANCE", uops)
20252028
self.assertNotIn("_TO_BOOL_BOOL", uops)
20262029
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)
2030+
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
20272031

20282032
def test_call_isinstance_unknown_object(self):
20292033
def testfunc(n):

0 commit comments

Comments
 (0)