diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2023-01-12 16:30:59 -0500 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2023-01-12 21:44:59 -0500 |
commit | 83d1175c32a0638460b51cc8ce7eb1df3a4cf949 (patch) | |
tree | 7e940bc4bc7e10052493753c814a564a8b25d043 | |
parent | 027728e17b31fb3ee685733c8b39a06b57158849 (diff) |
Update a bunch of no/low impact python2/3 references/comments
-rw-r--r-- | paramiko/util.py | 6 | ||||
-rw-r--r-- | paramiko/win_pageant.py | 5 | ||||
-rw-r--r-- | setup_helper.py | 7 | ||||
-rw-r--r-- | tests/test_client.py | 8 | ||||
-rw-r--r-- | tests/util.py | 4 |
5 files changed, 11 insertions, 19 deletions
diff --git a/paramiko/util.py b/paramiko/util.py index 5a21977e..2c6287b6 100644 --- a/paramiko/util.py +++ b/paramiko/util.py @@ -312,12 +312,12 @@ def asbytes(s): """ try: # Attempt to run through our version of b(), which does the Right Thing - # for string/unicode/buffer (Py2) or bytes/str (Py3), and raises - # TypeError if it's not one of those types. + # for unicode strings vs bytestrings, and raises TypeError if it's not + # one of those types. return b(s) except TypeError: try: - # If it wasn't a string/byte/buffer type object, try calling an + # If it wasn't a string/byte/buffer-ish object, try calling an # asbytes() method, which many of our internal classes implement. return s.asbytes() except AttributeError: diff --git a/paramiko/win_pageant.py b/paramiko/win_pageant.py index a1096ee8..780824c1 100644 --- a/paramiko/win_pageant.py +++ b/paramiko/win_pageant.py @@ -28,10 +28,7 @@ import struct from paramiko.common import zero_byte from paramiko.util import b -try: - import _thread as thread # Python 3.x -except ImportError: - import thread # Python 2.5-2.7 +import _thread as thread from . import _winapi diff --git a/setup_helper.py b/setup_helper.py index fc4e755f..8671fd63 100644 --- a/setup_helper.py +++ b/setup_helper.py @@ -134,12 +134,7 @@ def make_tarball( tar = tarfile.open(archive_name, mode=mode) # This recursively adds everything underneath base_dir try: - try: - # Support for the `filter' parameter was added in Python 2.7, - # earlier versions will raise TypeError. - tar.add(base_dir, filter=_set_uid_gid) - except TypeError: - tar.add(base_dir) + tar.add(base_dir, filter=_set_uid_gid) finally: tar.close() diff --git a/tests/test_client.py b/tests/test_client.py index cb34348a..c9e64c0b 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -443,7 +443,7 @@ class SSHClientTest(ClientTest): verify that when an SSHClient is collected, its transport (and the transport's packetizer) is closed. """ - # Skipped on PyPy because it fails on travis for unknown reasons + # Skipped on PyPy because it fails on CI for unknown reasons if platform.python_implementation() == "PyPy": return @@ -465,9 +465,9 @@ class SSHClientTest(ClientTest): # force a collection to see whether the SSHClient object is deallocated # 2 GCs are needed on PyPy, time is needed for Python 3 - # TODO: this still fails randomly under CircleCI under Python 3.7, 3.8 - # at the very least. bumped sleep 0.3->1.0s but the underlying - # functionality should get reevaluated once we drop Python 2. + # TODO 4.0: this still fails randomly under CircleCI under Python 3.7, + # 3.8 at the very least. bumped sleep 0.3->1.0s but the underlying + # functionality should get reevaluated now we've dropped Python 2. time.sleep(1) gc.collect() gc.collect() diff --git a/tests/util.py b/tests/util.py index 00642cb0..79ce2c61 100644 --- a/tests/util.py +++ b/tests/util.py @@ -137,8 +137,8 @@ def is_low_entropy(): """ Attempts to detect whether running interpreter is low-entropy. - Classified as being in 32-bit mode under Python 2, or 32-bit mode and with - the hash seed set to zero under Python 3. + "low-entropy" is defined as being in 32-bit mode and with the hash seed set + to zero. """ is_32bit = struct.calcsize("P") == 32 / 8 # I don't see a way to tell internally if the hash seed was set this |