diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2023-01-12 21:48:37 -0500 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2023-01-12 21:48:37 -0500 |
commit | b7052c5f520f272cf8217cb23fca2ddd1c6fcec4 (patch) | |
tree | 57e1dfe6478b038fddf04bf43426930a1e602152 | |
parent | a198ebd56c5eafd573e98f912bcf8aeec0c7e7d9 (diff) |
No more PKey.__cmp__
-rw-r--r-- | paramiko/pkey.py | 18 | ||||
-rw-r--r-- | sites/www/changelog.rst | 5 |
2 files changed, 5 insertions, 18 deletions
diff --git a/paramiko/pkey.py b/paramiko/pkey.py index d5ea27b6..2d189d9a 100644 --- a/paramiko/pkey.py +++ b/paramiko/pkey.py @@ -122,24 +122,6 @@ class PKey(object): def __bytes__(self): return self.asbytes() - # noinspection PyUnresolvedReferences - # TODO: The comparison functions should be removed as per: - # https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons - def __cmp__(self, other): - """ - Compare this key to another. Returns 0 if this key is equivalent to - the given key, or non-0 if they are different. Only the public parts - of the key are compared, so a public key will compare equal to its - corresponding private key. - - :param .PKey other: key to compare to. - """ - hs = hash(self) - ho = hash(other) - if hs != ho: - return cmp(hs, ho) # noqa - return cmp(self.asbytes(), other.asbytes()) # noqa - def __eq__(self, other): return isinstance(other, PKey) and self._fields == other._fields diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 63cb6d60..5e3af1a3 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,11 @@ Changelog ========= +- :support:`-` ``PKey.__cmp__`` has been removed. Ordering-oriented comparison + of key files is unlikely to have ever made sense (the old implementation + attempted to order by the hashes of the key material) and so we have not + bothered setting up ``__lt__`` and friends at this time. The class continues + to have its original ``__eq__`` untouched. - :bug:`- major` A handful of lower-level classes (notably `paramiko.message.Message` and `paramiko.pkey.PKey`) previously returned `bytes` objects from their implementation of ``__str__``, even under Python |