You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there,
First, thanks for this awesome library! However, I have a minor confusion about the input type of PTY.write() and I'd appreciate your explanation.
fromwinptyimportPTYcols, rows=80, 25process=PTY(cols, rows)
process.spawn("python.exe")
process.write('print(123)\r\n') # <-- line in questionprint(process.read(), end="", flush=True)
Through reading the README.md example and the doc-string here, I think process.write takes in a python bytes string, meaning I need to add a b in front of the string literal. However, if I do so, I get the following TypeError
TypeError: argument 'to_write': 'bytes' object cannot be converted to 'PyString'
The only way I can make it work is to pass a unicode string (default string for python3).
This is fine in most circumstances, as I can just decode the bytes into unicode string. However, in cases where we want to pass in certain control characters, e.g., ARROW UP (\xe0H) on my device and terminal, I cannot decode the bytes it into unicode. Is there a workaround?
FYI, I'm using an ARM-based Windows 11 via Parallels on a M2 MacBook Pro. The python version is 3.12.1. My python environment is pretty pristine with only the following packages installed
All the above packages are installed using pip install.
The text was updated successfully, but these errors were encountered:
shuheng-liu
changed the title
Question: PTY.write() takes unicode string or bytes?
Question: Does PTY.write() takes unicode string or bytes?
Dec 15, 2023
shuheng-liu
changed the title
Question: Does PTY.write() takes unicode string or bytes?
Question: Does PTY.write() take in unicode string or bytes?
Dec 15, 2023
Hi there,
First, thanks for this awesome library! However, I have a minor confusion about the input type of PTY.write() and I'd appreciate your explanation.
Through reading the README.md example and the doc-string here, I think process.write takes in a python
bytes
string, meaning I need to add ab
in front of the string literal. However, if I do so, I get the following TypeErrorThe only way I can make it work is to pass a unicode string (default string for python3).
This is fine in most circumstances, as I can just decode the bytes into unicode string. However, in cases where we want to pass in certain control characters, e.g., ARROW UP (
\xe0H
) on my device and terminal, I cannot decode the bytes it into unicode. Is there a workaround?FYI, I'm using an ARM-based Windows 11 via Parallels on a M2 MacBook Pro. The python version is 3.12.1. My python environment is pretty pristine with only the following packages installed
All the above packages are installed using
pip install
.The text was updated successfully, but these errors were encountered: