Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
05ae5ad
Add Ascii85, base85, and Z85 support to binascii
kangtastic Mar 8, 2023
aa06c5d
Restore base64.py
kangtastic Apr 26, 2025
6377440
Create _base64 module with wrappers for accelerated functions
kangtastic Apr 26, 2025
6c0e4a3
Test both Python and C codepaths in base64
kangtastic Apr 26, 2025
ce4773c
Match behavior between Python and C base 85 functions
kangtastic Apr 26, 2025
4072e3b
Add Z85 tests to binascii
kangtastic Apr 27, 2025
bc9217f
Update generated files
kangtastic Apr 27, 2025
2c40ba0
Avoid importing functools
kangtastic Apr 28, 2025
fd9eaf7
Avoid circular import in _base64
kangtastic Apr 28, 2025
4746d18
Do not use a decorator for changing exception type
kangtastic Apr 28, 2025
d075593
Test Python and C codepaths in base64 using mixins
kangtastic Apr 28, 2025
6d65fec
Remove leading underscore from functions in private module
kangtastic Apr 29, 2025
a241356
Merge branch 'main' into gh-101178-rework-base85
serhiy-storchaka Dec 24, 2025
0df9a40
Use more modern C API.
serhiy-storchaka Dec 24, 2025
60fbd7c
Fix tests.
serhiy-storchaka Dec 24, 2025
a070887
Merge branch 'main' into gh-101178-rework-base85
serhiy-storchaka Dec 25, 2025
167e83e
Fix new tests.
serhiy-storchaka Dec 25, 2025
01df442
Optimize binascii.b2a_ascii85().
serhiy-storchaka Dec 26, 2025
7885918
Apply suggestions from code review
serhiy-storchaka Dec 27, 2025
1e928e3
Update C style to more closely adhere to PEP-7
kangtastic Dec 28, 2025
2691a0a
Remove pure-Python base-85-related codepaths in base64
kangtastic Dec 28, 2025
b9d27bd
Remove now-unnecessary _base64 module and fix tests
kangtastic Dec 28, 2025
780517a
Separate Z85 from Base85 on the Python API side
kangtastic Dec 28, 2025
bc9a66d
Fix tests after separating Base85 from Z85
kangtastic Dec 28, 2025
dc1d3fc
Merge branch 'main' into gh-101178-rework-base85
kangtastic Dec 28, 2025
c5de5a1
Update generated files after merging main
kangtastic Dec 28, 2025
3bb3b18
Update Misc/NEWS.d and Misc/ACKS
kangtastic Dec 28, 2025
6f09fa8
Update generated files again
kangtastic Dec 29, 2025
6d8f897
Fix typo in NEWS entry
kangtastic Dec 29, 2025
3582492
Merge branch 'main' into gh-101178-rework-base85
serhiy-storchaka Jan 14, 2026
879dd86
Move the NEWS entry to the correct section.
serhiy-storchaka Jan 14, 2026
3cdc3c5
Minor cleanups, align lookup tables to 64 bytes (NFC)
kangtastic Jan 17, 2026
8adaf2c
Allow up to sys.maxsize output length when encoding base 85
kangtastic Jan 18, 2026
2b2ecc4
Fix Ascii85 test from mainline
kangtastic Jan 18, 2026
da165d1
Allow up to sys.maxsize output length when decoding base 85
kangtastic Jan 18, 2026
bf32f99
Defer base 85 overflow check during decoding
kangtastic Jan 18, 2026
74f6ceb
Merge branch 'main' into gh-101178-rework-base85
kangtastic Jan 18, 2026
4ba3e50
Merge branch 'main' into gh-101178-rework-base85
serhiy-storchaka Feb 6, 2026
99e0bde
Rename parameters to match the base64 module.
serhiy-storchaka Feb 6, 2026
cc6d485
Remove parameters strict_mode and newline.
serhiy-storchaka Feb 6, 2026
30f54a1
Optimize ignorechars cache.
serhiy-storchaka Feb 6, 2026
37df735
Harmonize documentation.
serhiy-storchaka Feb 6, 2026
56a02b2
Add What's New entries.
serhiy-storchaka Feb 6, 2026
adb1922
Polish tests.
serhiy-storchaka Feb 6, 2026
0730fdf
Rename internal Base 85 codec functions to match Base 64 helpers
kangtastic Feb 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests.
  • Loading branch information
serhiy-storchaka committed Dec 24, 2025
commit 60fbd7c42de22f8ad82ba06467a93b9396cbecab
12 changes: 12 additions & 0 deletions Lib/test/test_base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_decodebytes(self):
@hypothesis.given(payload=hypothesis.strategies.binary())
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz')
def test_bytes_encode_decode_round_trip(self, payload):
base64 = self.module
encoded = base64.encodebytes(payload)
decoded = base64.decodebytes(encoded)
self.assertEqual(payload, decoded)
Expand Down Expand Up @@ -115,6 +116,7 @@ def test_decode(self):
@hypothesis.given(payload=hypothesis.strategies.binary())
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz')
def test_legacy_encode_decode_round_trip(self, payload):
base64 = self.module
from io import BytesIO
payload_file_r = BytesIO(payload)
encoded_file_w = BytesIO()
Expand Down Expand Up @@ -271,6 +273,7 @@ def test_b64decode(self):

def test_b64decode_altchars(self):
# Test with arbitrary alternative characters
base64 = self.module
eq = self.assertEqual
res = b'\xd3V\xbeo\xf7\x1d'
for altchars in b'*$', b'+/', b'/+', b'+_', b'-+', b'-/', b'/_':
Expand Down Expand Up @@ -342,6 +345,7 @@ def _altchars_strategy():
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', b"_-", True)
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', b"_-", False)
def test_b64_encode_decode_round_trip(self, payload, altchars, validate):
base64 = self.module
encoded = base64.b64encode(payload, altchars=altchars)
decoded = base64.b64decode(encoded, altchars=altchars,
validate=validate)
Expand All @@ -350,13 +354,15 @@ def test_b64_encode_decode_round_trip(self, payload, altchars, validate):
@hypothesis.given(payload=hypothesis.strategies.binary())
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz')
def test_standard_b64_encode_decode_round_trip(self, payload):
base64 = self.module
encoded = base64.standard_b64encode(payload)
decoded = base64.standard_b64decode(encoded)
self.assertEqual(payload, decoded)

@hypothesis.given(payload=hypothesis.strategies.binary())
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz')
def test_urlsafe_b64_encode_decode_round_trip(self, payload):
base64 = self.module
encoded = base64.urlsafe_b64encode(payload)
decoded = base64.urlsafe_b64decode(encoded)
self.assertEqual(payload, decoded)
Expand Down Expand Up @@ -419,6 +425,7 @@ def test_b32decode_casefold(self):

def test_b32decode_map01(self):
# Mapping zero and one
base64 = self.module
eq = self.assertEqual
res_L = b'b\xdd\xad\xf3\xbe'
res_I = b'b\x1d\xad\xf3\xbe'
Expand Down Expand Up @@ -471,6 +478,7 @@ def test_b32decode_error(self):
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True, None)
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False, None)
def test_b32_encode_decode_round_trip(self, payload, casefold, map01):
base64 = self.module
encoded = base64.b32encode(payload)
decoded = base64.b32decode(encoded, casefold=casefold, map01=map01)
self.assertEqual(payload, decoded)
Expand Down Expand Up @@ -555,6 +563,7 @@ def test_b32hexdecode_error(self):
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True)
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False)
def test_b32_hexencode_decode_round_trip(self, payload, casefold):
base64 = self.module
encoded = base64.b32hexencode(payload)
decoded = base64.b32hexdecode(encoded, casefold=casefold)
self.assertEqual(payload, decoded)
Expand Down Expand Up @@ -603,6 +612,7 @@ def test_b16decode(self):
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True)
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False)
def test_b16_encode_decode_round_trip(self, payload, casefold):
base64 = self.module
endoded = base64.b16encode(payload)
decoded = base64.b16decode(endoded, casefold=casefold)
self.assertEqual(payload, decoded)
Expand Down Expand Up @@ -971,6 +981,7 @@ def add_padding(self, payload):
def test_a85_encode_decode_round_trip(
self, payload, foldspaces, wrapcol, pad, adobe
):
base64 = self.module
encoded = base64.a85encode(
payload, foldspaces=foldspaces, wrapcol=wrapcol,
pad=pad, adobe=adobe,
Expand All @@ -997,6 +1008,7 @@ def test_a85_encode_decode_round_trip(
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True)
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False)
def test_b85_encode_decode_round_trip(self, payload, pad):
base64 = self.module
encoded = base64.b85encode(payload, pad=pad)
if pad:
payload = self.add_padding(payload)
Expand Down
Loading