Remaining asserts

This commit is contained in:
Stan Ulbrych 2025-07-24 10:22:15 +02:00
parent cb8197ad6d
commit f7d77c4841
No known key found for this signature in database
GPG key ID: B8E58DBDB2A1A0B8
5 changed files with 39 additions and 20 deletions

View file

@ -11,11 +11,16 @@
import binascii
from io import BytesIO
### Codec Helpers
def _assert_strict(errors):
if errors != 'strict':
raise ValueError(f'Unsupported error handling mode: "{errors}" - must be "strict"')
### Codec APIs
def uu_encode(input, errors='strict', filename='<data>', mode=0o666):
if errors != 'strict':
raise ValueError(f'Unsupported error handling mode: "{errors}" - must be "strict"')
_assert_strict(errors)
infile = BytesIO(input)
outfile = BytesIO()
read = infile.read
@ -36,8 +41,7 @@ def uu_encode(input, errors='strict', filename='<data>', mode=0o666):
return (outfile.getvalue(), len(input))
def uu_decode(input, errors='strict'):
if errors != 'strict':
raise ValueError(f'Unsupported error handling mode: "{errors}" - must be "strict"')
_assert_strict(errors)
infile = BytesIO(input)
outfile = BytesIO()
readline = infile.readline