-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Original report by Henry Perschk (Bitbucket: [Henry Perschk](https://bitbucket.org/Henry Perschk), ).
Python 3.7.0, Sarge 0.1.5.post0 (through pip).
I followed the tutorial part "Interacting with child processes".
With Python 3, I had to execute the example slightly differently to get it to work. Please consider changing the docs, or telling me if I did something wrong :)
-
>>> p.stdin.write('Fred\n')has to be passed a bytes object (p.stdin.write(b'Fred\n')) (otherwise: TypeError: a bytes-like object is required, not 'str'). -
>>> p.stdin.write('Fred\n')
>>> p.stdout.readline()
requires p.stdin.flush() to be called after writing to stdin, otherwise stdout will be empty.
There seems to be some kind of bug in Popen (see: https://stackoverflow.com/questions/27571305/subprocess-stdin-buffer-not-flushing-on-newline-with-bufsize-1), but even adding the suggested universal_newlines=True to the Command object didn't work for me (stdout empty, only works when flushing stdin).