Skip to content

Commit

Permalink
Merge branch '2.9' into 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Apr 25, 2022
2 parents 7a2c84a + d7fe051 commit 47529be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion paramiko/pkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __cmp__(self, other):
return cmp(self.asbytes(), other.asbytes()) # noqa

def __eq__(self, other):
return self._fields == other._fields
return isinstance(other, PKey) and self._fields == other._fields

def __hash__(self):
return hash(self._fields)
Expand Down
6 changes: 6 additions & 0 deletions sites/www/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog
=========

- :bug:`1964` (via :issue:`2024` as also reported in :issue:`2023`)
`~paramiko.pkey.PKey` instances' ``__eq__`` did not have the usual safety
guard in place to ensure they were being compared to another ``PKey`` object,
causing occasional spurious ``BadHostKeyException`` (among other things).
This has been fixed. Thanks to Shengdun Hua for the original report/patch and
to Christopher Papke for the final version of the fix.
- :bug:`2035` Servers offering certificate variants of hostkey algorithms (eg
``[email protected]``) could not have their host keys verified by
Paramiko clients, as it only ever considered non-cert key types for that part
Expand Down
5 changes: 5 additions & 0 deletions tests/test_pkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,11 @@ def test_keys_are_comparable(self):
for key1, key2 in self.keys():
assert key1 == key2

def test_keys_are_not_equal_to_other(self):
for value in [None, True, ""]:
for key1, _ in self.keys():
assert key1 != value

def test_keys_are_hashable(self):
# NOTE: this isn't a great test due to hashseed randomization under
# Python 3 preventing use of static values, but it does still prove
Expand Down

0 comments on commit 47529be

Please sign in to comment.