# HG changeset patch # User Mads Kiilerich # Date 1602328273 -7200 # Node ID be839636b6e44b6a2836e800a96d4ab849331064 # Parent a3f649baa0166afd749dd74aa609b6333de146ea ssh: import binascii directly, instead of using it through base64 module It is unfortunate that the base64 module is leaking its binascii internals in exception types. We started using binascii through the base64 import in 08af13a090e0, but the import is not public, and pytype thus complains. diff -r a3f649baa016 -r be839636b6e4 kallithea/lib/ssh.py --- a/kallithea/lib/ssh.py Sat Oct 10 13:45:52 2020 +0200 +++ b/kallithea/lib/ssh.py Sat Oct 10 13:11:13 2020 +0200 @@ -22,6 +22,7 @@ # along with this program. If not, see . import base64 +import binascii import logging import re import struct @@ -109,7 +110,7 @@ try: key_bytes = base64.b64decode(keyvalue) - except base64.binascii.Error: # Must be caused by truncation - either "Invalid padding" or "Invalid base64-encoded string: number of data characters (x) cannot be 1 more than a multiple of 4" + except binascii.Error: # Must be caused by truncation - either "Invalid padding" or "Invalid base64-encoded string: number of data characters (x) cannot be 1 more than a multiple of 4" raise SshKeyParseError(_("Invalid SSH key - base64 part %r seems truncated (it can't be decoded)") % keyvalue) # Check key internals to make sure the key wasn't truncated in a way that base64 can decode: