Make b64encode raises properly a TypeError when altchars is not bytes.

This commit is contained in:
Alexandre Vassalotti 2009-06-29 01:13:41 +00:00
parent 70f52768fd
commit 5629268e9d
1 changed files with 2 additions and 2 deletions

View File

@ -58,7 +58,7 @@ def b64encode(s, altchars=None):
encoded = binascii.b2a_base64(s)[:-1] encoded = binascii.b2a_base64(s)[:-1]
if altchars is not None: if altchars is not None:
if not isinstance(altchars, bytes_types): if not isinstance(altchars, bytes_types):
altchars = TypeError("expected bytes, not %s" raise TypeError("expected bytes, not %s"
% altchars.__class__.__name__) % altchars.__class__.__name__)
assert len(altchars) == 2, repr(altchars) assert len(altchars) == 2, repr(altchars)
return _translate(encoded, {'+': altchars[0:1], '/': altchars[1:2]}) return _translate(encoded, {'+': altchars[0:1], '/': altchars[1:2]})