From 4477aaeccef1c5d130ffcd795c46c4c7a3caca93 Mon Sep 17 00:00:00 2001 From: Archetrix Date: Thu, 30 Jun 2016 13:19:12 +0200 Subject: [PATCH] Solve possible UnboundLocalError. Happened to me (see below). I know handling this case could be done different (stop/return after closing the socket probably), but my insight to the possible consequences is limited so i opted for the obvious solution to declare "bytes_written" ... Traceback (most recent call last): File "/usr/bin/parallel-ssh", line 119, in do_pssh(hosts, cmdline, opts) File "/usr/bin/parallel-ssh", line 110, in do_pssh manager.run() File "/usr/lib/pymodules/python2.6/psshlib/manager.py", line 67, in run self.iomap.poll(wait) File "/usr/lib/pymodules/python2.6/psshlib/manager.py", line 242, in poll handler(fd, self) File "/usr/lib/pymodules/python2.6/psshlib/askpass_server.py", line 77, in handle_write buffer = buffer[bytes_written:] UnboundLocalError: local variable 'bytes_written' referenced before assignment --- psshlib/askpass_server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/psshlib/askpass_server.py b/psshlib/askpass_server.py index 4293164..0104bb8 100644 --- a/psshlib/askpass_server.py +++ b/psshlib/askpass_server.py @@ -68,6 +68,7 @@ def handle_listen(self, fd, iomap): def handle_write(self, fd, iomap): buffer = self.buffermap[fd] conn = self.socketmap[fd] + bytes_written = 0 try: bytes_written = conn.send(buffer) except socket.error: