# HG changeset patch # User Mads Kiilerich # Date 2020-01-25 19:53:56 # Node ID 08af13a090e0fc0d4e74ecf8694c15a7381b2524 # Parent 02c119ae72e1f2360e966df73e457185bad85429 py3: update ssh for base64.b64decode raising binascii.Error instead of TypeError A command like: python -c 'import base64; base64.b64decode("QQ")' would fail in Python2 with: TypeError: Incorrect padding but in python3: binascii.Error: Incorrect padding diff --git a/kallithea/lib/ssh.py b/kallithea/lib/ssh.py --- a/kallithea/lib/ssh.py +++ b/kallithea/lib/ssh.py @@ -87,7 +87,7 @@ def parse_pub_key(ssh_key): try: key_bytes = base64.b64decode(keyvalue) - except TypeError: + except base64.binascii.Error: raise SshKeyParseError(_("Incorrect SSH key - failed to decode base64 part %r") % keyvalue) if not key_bytes.startswith(b'\x00\x00\x00%c%s\x00' % (len(keytype), ascii_bytes(keytype))):