From 25eb7ca836acf5ea3a56cabfba9d33b08c4a6dd5 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Mon, 16 Jan 2023 22:00:33 -0500 Subject: Handpick remaining-ly relevant changes from #2110 Also make 'em f-strings, which AFAIK should be comparable Closes #2110 --- paramiko/util.py | 4 ++-- sites/www/changelog.rst | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/paramiko/util.py b/paramiko/util.py index 76941ff4..f1e33a50 100644 --- a/paramiko/util.py +++ b/paramiko/util.py @@ -323,7 +323,7 @@ def b(s, encoding="utf8"): elif isinstance(s, str): return s.encode(encoding) else: - raise TypeError("Expected unicode or bytes, got {!r}".format(s)) + raise TypeError(f"Expected unicode or bytes, got {type(s)}") # TODO: clean this up / force callers to assume bytes OR unicode @@ -334,4 +334,4 @@ def u(s, encoding="utf8"): elif isinstance(s, str): return s else: - raise TypeError("Expected unicode or bytes, got {!r}".format(s)) + raise TypeError(f"Expected unicode or bytes, got {type(s)}") diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 258fe1f8..ed424e29 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,11 @@ Changelog ========= +- :bug:`2110 major` Remove some unnecessary ``__repr__`` calls when handling + bytes-vs-str conversions. This was apparently doing a lot of unintentional + data processing, which adds up in some use cases -- such as SFTP transfers, + which may now be significantly faster. Kudos to Shuhua Zhong for catch & + patch. - :bug:`2165 major` Streamline some redundant (and costly) byte conversion calls in the packetizer and the core SFTP module. This should lead to some SFTP speedups at the very least. Thanks to Alex Gaynor for the patch. -- cgit v1.2.1