Simplify base64 input and output parameters. (#2587)

This allows passing bytearray() objects to the base64 encode and decode functions, on both Python 2.7 and 3.4.

This also simplifies the code by ignoring 3.2 and 3.3, which are out of scope.
This commit is contained in:
Diego Elio Pettenò
2018-11-06 18:24:16 +00:00
committed by Sebastian Rittau
parent 744f572c68
commit 0ebba82bfc

View File

@@ -4,17 +4,11 @@ from typing import IO, Union, Text
import sys
if sys.version_info < (3,):
_encodable = Union[bytes, Text]
_decodable = Union[bytes, Text]
elif sys.version_info < (3, 3):
_encodable = bytes
_decodable = bytes
elif sys.version_info[:2] == (3, 3):
_encodable = Union[bytes, unicode]
_decodable = Union[bytes, unicode]
else:
_encodable = bytes
_decodable = Union[bytes, str]
elif sys.version_info >= (3, 4):
_encodable = Union[bytes, bytearray, memoryview]
_decodable = Union[bytes, bytearray, memoryview, str]
def b64encode(s: _encodable, altchars: bytes = ...) -> bytes: ...
def b64decode(s: _decodable, altchars: bytes = ...,