I am trying to use pexpect module (version 4.8.0) with Python 3.6.8. I get an error
TypeError: cannot use a string pattern on a bytes-like object
Here is my code:
buff = BytesIO()
child = pexpect.spawn(path, args, logfile=buff, timeout=self.PASSPHRASE_TIMEOUT, **kwargs)
while True:
idx = child.expect([self.PASSPHRASE_RE,pexpect.EOF])
if idx == 0:
child.sendline(passphrase)
elif idx == 1:
child.wait()
break
I am getting an error in line idx = child.expect([self.PASSPHRASE_RE,pexpect.EOF])
Note: I have already tried some solutions that are there on StackOverflow like:
- pass encoding('utf-8') parameter in pexpect.spawn.
- Replace pexpect.spawn with pexpect.spawnu
But no luck again same error.
Please please help me I have alreday wasted 3 days to resolve this errors.