]> granicus.if.org Git - python/commitdiff
Make b64encode raises properly a TypeError when altchars is not bytes.
authorAlexandre Vassalotti <alexandre@peadrop.com>
Mon, 29 Jun 2009 01:13:41 +0000 (01:13 +0000)
committerAlexandre Vassalotti <alexandre@peadrop.com>
Mon, 29 Jun 2009 01:13:41 +0000 (01:13 +0000)
Lib/base64.py

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