diff options
author | Guido van Rossum <guido@python.org> | 2007-08-27 21:47:52 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-08-27 21:47:52 (GMT) |
commit | 98b349f8e6efc5c1994e506c02a755f311d49f03 (patch) | |
tree | 2eb82600c7f8eff6ed00ae6253ee2e78b3c15f2b /Lib/base64.py | |
parent | 1f2ca56e296bea2e1374458a7ec40692e7145174 (diff) | |
download | cpython-98b349f8e6efc5c1994e506c02a755f311d49f03.zip cpython-98b349f8e6efc5c1994e506c02a755f311d49f03.tar.gz cpython-98b349f8e6efc5c1994e506c02a755f311d49f03.tar.bz2 |
Fix some tests I broke. (More to follow.)
Diffstat (limited to 'Lib/base64.py')
-rwxr-xr-x | Lib/base64.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/base64.py b/Lib/base64.py index cec6422..5d42065 100755 --- a/Lib/base64.py +++ b/Lib/base64.py @@ -28,7 +28,8 @@ __all__ = [ def _translate(s, altchars): - assert isinstance(s, bytes), type(s) + if not isinstance(s, bytes): + raise TypeError("expected bytes, not %s" % s.__class__.__name__) translation = bytes(range(256)) for k, v in altchars.items(): translation[ord(k)] = v[0] @@ -323,7 +324,8 @@ def decode(input, output): def encodestring(s): """Encode a string into multiple lines of base-64 data.""" - assert isinstance(s, bytes), repr(s) + if not isinstance(s, bytes): + raise TypeError("expected bytes, not %s" % s.__class__.__name__) pieces = [] for i in range(0, len(s), MAXBINSIZE): chunk = s[i : i + MAXBINSIZE] @@ -333,7 +335,8 @@ def encodestring(s): def decodestring(s): """Decode a string.""" - assert isinstance(s, bytes), repr(s) + if not isinstance(s, bytes): + raise TypeError("expected bytes, not %s" % s.__class__.__name__) return binascii.a2b_base64(s) |