4

I'm having an issue when using spawnu (UTF-8) from the Pexpect module for Python 3 during a SSH session when the remote machine responds with the following characters in the output:

ÿÿÿÿ

Here's the error the I received:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 273: invalid start byte

When I throw an interact() in before I receive the input, everything comes through okay, which is why I believe the issue is with spawnu.

I'm looking for workarounds or alternative methods.

Grant Miller
  • 27,532
  • 16
  • 147
  • 165
Brian Kilo
  • 41
  • 3

1 Answers1

2

add codec_errors='ignore' after encoding

something like:

proc = pexpect.spawn(command, timeout=timeout, maxread=maxread, logfile=context.log, encoding='utf-8', codec_errors='ignore')
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103