paramiko-expect icon indicating copy to clipboard operation
paramiko-expect copied to clipboard

IndexError with ANSI codes

Open sergehauri opened this issue 4 years ago • 0 comments

In the expect method, when self.current_output is still empty and current_buffer_decoded is empty because the current_buffer only contains an ANSI escape code (and strip_ansi is True), the following exception is raised:

  File "/srv/www/rantools/venvs/infenv3/lib/python3.6/site-packages/paramiko_expect.py", line 191, in expect
    current_buffer_output_decoded = '\n' + self.current_output.splitlines()[-1]
IndexError: list index out of range

I refrained from setting up a reproducible example because I think the error is easy enough to understand from the code alone. Easiest would probably be to only change current_buffer_output_decoded if self.current_output isn't empty.

sergehauri avatar Oct 08 '21 09:10 sergehauri