pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / by-name / rc / rcu / Port-to-paramiko-3.x.patch
blob760d23cea18d30c6181f421ee4382096da915a86
1 From aad61b320d65953fddec10b019a186fc67f57a5d Mon Sep 17 00:00:00 2001
2 From: OPNA2608 <opna2608@protonmail.com>
3 Date: Sat, 10 Feb 2024 12:20:29 +0100
4 Subject: [PATCH] src/model/transport.py: Port to paramiko 3.x
6 ---
7 src/model/transport.py | 19 +++++++++----------
8 1 file changed, 9 insertions(+), 10 deletions(-)
10 diff --git a/src/model/transport.py b/src/model/transport.py
11 index 0c2ee16..5a2bd22 100644
12 --- a/src/model/transport.py
13 +++ b/src/model/transport.py
14 @@ -117,7 +117,6 @@ from paramiko.kex_gss import KexGSSGex, KexGSSGroup1, KexGSSGroup14
15 from paramiko.message import Message
16 from paramiko.packet import Packetizer, NeedRekeyException
17 from paramiko.primes import ModulusPack
18 -from paramiko.py3compat import string_types, long, byte_ord, b, input, PY2
19 from paramiko.rsakey import RSAKey
20 from paramiko.ecdsakey import ECDSAKey
21 from paramiko.server import ServerInterface
22 @@ -128,7 +127,7 @@ from paramiko.ssh_exception import (
23 ChannelException,
24 ProxyCommandFailure,
26 -from paramiko.util import retry_on_signal, ClosingContextManager, clamp_value
27 +from paramiko.util import ClosingContextManager, clamp_value
30 # for thread cleanup
31 @@ -396,7 +395,7 @@ class Transport(threading.Thread, ClosingContextManager):
32 self.active = False
33 self.hostname = None
35 - if isinstance(sock, string_types):
36 + if isinstance(sock, str):
37 # convert "host:port" into (host, port)
38 hl = sock.split(":", 1)
39 self.hostname = hl[0]
40 @@ -419,7 +418,7 @@ class Transport(threading.Thread, ClosingContextManager):
41 sock = socket.socket(af, socket.SOCK_STREAM)
42 sock.settimeout(1)
43 try:
44 - retry_on_signal(lambda: sock.connect((hostname, port)))
45 + sock.connect((hostname, port))
46 except socket.error as e:
47 reason = str(e)
48 else:
49 @@ -542,7 +541,7 @@ class Transport(threading.Thread, ClosingContextManager):
50 """
51 Returns a string representation of this object, for debugging.
52 """
53 - id_ = hex(long(id(self)) & xffffffff)
54 + id_ = hex(int(id(self)) & xffffffff)
55 out = "<paramiko.Transport at {}".format(id_)
56 if not self.active:
57 out += " (unconnected)"
58 @@ -1123,7 +1122,7 @@ class Transport(threading.Thread, ClosingContextManager):
59 m = Message()
60 m.add_byte(cMSG_IGNORE)
61 if byte_count is None:
62 - byte_count = (byte_ord(os.urandom(1)) % 32) + 10
63 + byte_count = (os.urandom(1) % 32) + 10
64 m.add_bytes(os.urandom(byte_count))
65 self._send_user_message(m)
67 @@ -1802,7 +1801,7 @@ class Transport(threading.Thread, ClosingContextManager):
68 def stop_thread(self):
69 self.active = False
70 self.packetizer.close()
71 - if PY2:
72 + if False:
73 # Original join logic; #520 doesn't appear commonly present under
74 # Python 2.
75 while self.is_alive() and self is not threading.current_thread():
76 @@ -1909,7 +1908,7 @@ class Transport(threading.Thread, ClosingContextManager):
77 m = Message()
78 m.add_mpint(self.K)
79 m.add_bytes(self.H)
80 - m.add_byte(b(id))
81 + m.add_byte(id.encode("utf8"))
82 m.add_bytes(self.session_id)
83 # Fallback to SHA1 for kex engines that fail to specify a hex
84 # algorithm, or for e.g. transport tests that don't run kexinit.
85 @@ -2037,14 +2036,14 @@ class Transport(threading.Thread, ClosingContextManager):
87 # active=True occurs before the thread is launched, to avoid a race
88 _active_threads.append(self)
89 - tid = hex(long(id(self)) & xffffffff)
90 + tid = hex(int(id(self)) & xffffffff)
91 if self.server_mode:
92 self._log(DEBUG, "starting thread (server mode): {}".format(tid))
93 else:
94 self._log(DEBUG, "starting thread (client mode): {}".format(tid))
95 try:
96 try:
97 - self.packetizer.write_all(b(self.local_version + "\r\n"))
98 + self.packetizer.write_all((self.local_version + "\r\n").encode("utf8"))
99 self._log(
100 DEBUG,
101 "Local version/idstring: {}".format(self.local_version),
103 2.42.0