mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Remaining asserts
This commit is contained in:
parent
cb8197ad6d
commit
f7d77c4841
5 changed files with 39 additions and 20 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue