summaryrefslogtreecommitdiff
path: root/paramiko/kex_gss.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2017-10-10 18:24:34 -0700
committerJeff Forcier <jeff@bitprophet.org>2017-10-10 18:24:38 -0700
commit29ac57f565ac94021dee46b365daa56a3d27333e (patch)
treedda22abe6f5eba8118b225c55fac2f7a09237e4e /paramiko/kex_gss.py
parent9019b25497c2b143e06da6a393e24b67bfc848f0 (diff)
downloadparamiko-1070-remove-python26-and-33.tar.gz
String format modernization, part 11070-remove-python26-and-33
Choosing to skip it in some edge/corner cases where it's more harmful than helpful. Also choosing to replace many non-%s specifiers with regular old {} since I don't see why one would normally care. Again, eschewing that in spots where it seems like it might matter.
Diffstat (limited to 'paramiko/kex_gss.py')
-rw-r--r--paramiko/kex_gss.py35
1 files changed, 20 insertions, 15 deletions
diff --git a/paramiko/kex_gss.py b/paramiko/kex_gss.py
index a2ea9fca..e21620fe 100644
--- a/paramiko/kex_gss.py
+++ b/paramiko/kex_gss.py
@@ -120,8 +120,8 @@ class KexGSSGroup1(object):
return self._parse_kexgss_complete(m)
elif ptype == MSG_KEXGSS_ERROR:
return self._parse_kexgss_error(m)
- raise SSHException('GSS KexGroup1 asked to handle packet type %d'
- % ptype)
+ msg = 'GSS KexGroup1 asked to handle packet type {:d}'
+ raise SSHException(msg.format(ptype))
# ## internals...
@@ -282,10 +282,11 @@ class KexGSSGroup1(object):
min_status = m.get_int()
err_msg = m.get_string()
m.get_string() # we don't care about the language!
- raise SSHException("GSS-API Error:\nMajor Status: %s\nMinor Status: %s\
- \nError Message: %s\n") % (str(maj_status),
- str(min_status),
- err_msg)
+ raise SSHException("""GSS-API Error:
+Major Status: {}
+Minor Status: {}
+Error Message: {}
+""".format(maj_status, min_status, err_msg))
class KexGSSGroup14(KexGSSGroup1):
@@ -361,7 +362,8 @@ class KexGSSGex(object):
return self._parse_kexgss_complete(m)
elif ptype == MSG_KEXGSS_ERROR:
return self._parse_kexgss_error(m)
- raise SSHException('KexGex asked to handle packet type %d' % ptype)
+ msg = 'KexGex asked to handle packet type {:d}'
+ raise SSHException(msg.format(ptype))
# ## internals...
@@ -416,8 +418,10 @@ class KexGSSGex(object):
'Can\'t do server-side gex with no modulus pack')
self.transport._log(
DEBUG, # noqa
- 'Picking p (%d <= %d <= %d bits)' % (
- minbits, preferredbits, maxbits))
+ 'Picking p ({} <= {} <= {} bits)'.format(
+ minbits, preferredbits, maxbits,
+ )
+ )
self.g, self.p = pack.get_modulus(minbits, preferredbits, maxbits)
m = Message()
m.add_byte(c_MSG_KEXGSS_GROUP)
@@ -439,8 +443,8 @@ class KexGSSGex(object):
if (bitlen < 1024) or (bitlen > 8192):
raise SSHException(
'Server-generated gex p (don\'t ask) is out of range '
- '(%d bits)' % bitlen)
- self.transport._log(DEBUG, 'Got server p (%d bits)' % bitlen) # noqa
+ '({} bits)'.format(bitlen))
+ self.transport._log(DEBUG, 'Got server p ({} bits)'.format(bitlen)) # noqa
self._generate_x()
# now compute e = g^x mod p
self.e = pow(self.g, self.x, self.p)
@@ -603,10 +607,11 @@ class KexGSSGex(object):
min_status = m.get_int()
err_msg = m.get_string()
m.get_string() # we don't care about the language (lang_tag)!
- raise SSHException("GSS-API Error:\nMajor Status: %s\nMinor Status: %s\
- \nError Message: %s\n") % (str(maj_status),
- str(min_status),
- err_msg)
+ raise SSHException("""GSS-API Error:
+Major Status: {}
+Minor Status: {}
+Error Message: {}
+""".format(maj_status, min_status, err_msg))
class NullHostKey(object):