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
Do not use a decorator for changing exception type
Using a decorator complicates function signature introspection.
  • Loading branch information
kangtastic committed Apr 28, 2025
commit 4746d18185d167589a1630d7221e6f9d109f665e
49 changes: 26 additions & 23 deletions Lib/_base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,51 @@ def _bytes_from_encode_data(b):


# Functions in binascii raise binascii.Error instead of ValueError.
def raise_valueerror(func):
def _func(*args, **kwargs):
try:
return func(*args, **kwargs)
except Error as e:
raise ValueError(e) from None
return _func


@raise_valueerror
def _a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False):
b = _bytes_from_encode_data(b)
return b2a_ascii85(b, fold_spaces=foldspaces,
wrap=adobe, width=wrapcol, pad=pad)
try:
return b2a_ascii85(b, fold_spaces=foldspaces,
wrap=adobe, width=wrapcol, pad=pad)
except Error as e:
raise ValueError(e) from None


@raise_valueerror
def _a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v'):
b = _bytes_from_decode_data(b)
return a2b_ascii85(b, fold_spaces=foldspaces,
wrap=adobe, ignore=ignorechars)

try:
return a2b_ascii85(b, fold_spaces=foldspaces,
wrap=adobe, ignore=ignorechars)
except Error as e:
raise ValueError(e) from None

@raise_valueerror
def _b85encode(b, pad=False):
b = _bytes_from_encode_data(b)
return b2a_base85(b, pad=pad, newline=False)
try:
return b2a_base85(b, pad=pad, newline=False)
except Error as e:
raise ValueError(e) from None


@raise_valueerror
def _b85decode(b):
b = _bytes_from_decode_data(b)
return a2b_base85(b, strict_mode=True)
try:
return a2b_base85(b, strict_mode=True)
except Error as e:
raise ValueError(e) from None


@raise_valueerror
def _z85encode(s):
s = _bytes_from_encode_data(s)
return b2a_base85(s, newline=False, z85=True)
try:
return b2a_base85(s, newline=False, z85=True)
except Error as e:
raise ValueError(e) from None


@raise_valueerror
def _z85decode(s):
s = _bytes_from_decode_data(s)
return a2b_base85(s, strict_mode=True, z85=True)
try:
return a2b_base85(s, strict_mode=True, z85=True)
except Error as e:
raise ValueError(e) from None