Skip to content

Conversation

@Archetrix
Copy link

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

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 <module>
    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
@quinkennedy
Copy link
Contributor

It seems to me that we should return at the end of the catch. But it is also good practice to declare variables before their use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants