From 80556bdc9944df60eb0a06c3985bcf2dae1376e2 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Fri, 14 Apr 2023 12:19:40 -0400 Subject: Fix now-broken-on-py3 AgentKey.__str__, by deleting it --- paramiko/agent.py | 3 --- sites/www/changelog.rst | 3 +++ tests/test_agent.py | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/paramiko/agent.py b/paramiko/agent.py index 30ec1590..8aa8d9a3 100644 --- a/paramiko/agent.py +++ b/paramiko/agent.py @@ -428,9 +428,6 @@ class AgentKey(PKey): def asbytes(self): return self.blob - def __str__(self): - return self.asbytes() - def get_name(self): return self.name diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 0b2022ca..d93c0494 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,9 @@ Changelog ========= +- :bug:`-` `~paramiko.agent.AgentKey` had a dangling Python 3 incompatible + ``__str__`` method returning bytes. This method has been removed, allowing + the superclass' (`~paramiko.pkey.PKey`) method to run instead. - :release:`3.1.0 <2023-03-10>` - :feature:`2013` (solving :issue:`2009`, plus others) Add an explicit ``channel_timeout`` keyword argument to `paramiko.client.SSHClient.connect`, diff --git a/tests/test_agent.py b/tests/test_agent.py index 01602d0e..a00011bf 100644 --- a/tests/test_agent.py +++ b/tests/test_agent.py @@ -48,3 +48,10 @@ class AgentTests(unittest.TestCase): kwargs=dict(algorithm="rsa-sha2-512"), expectation=SSH_AGENT_RSA_SHA2_512, ) + + def test_agent_key_str_kinda_fixed(self): + # Tests for a missed spot in Python 3 upgrades: AgentKey.__str__ was + # returning bytes, as if under Python 2. When bug present, this + # explodes with "__str__ returned non-string". + key = AgentKey(ChaosAgent(), b("secret!!!")) + assert str(key) == repr(key) -- cgit v1.2.3