diff -r 19b2c54e5f09 Doc/library/pty.rst --- a/Doc/library/pty.rst Wed Nov 12 10:23:44 2014 -0500 +++ b/Doc/library/pty.rst Thu Nov 13 13:00:21 2014 -0500 @@ -43,7 +43,9 @@ The functions *master_read* and *stdin_read* should be functions which read from a file descriptor. The defaults try to read 1024 bytes each time they are - called. + called. Returning an empty string will be interpreted as an EOF + condition. In order to silently ignore input or output, *None* + should be returned from the appropriate *_read* function. .. versionchanged:: 3.4 :func:`spawn` now returns the status value from :func:`os.waitpid` diff -r 19b2c54e5f09 Lib/pty.py --- a/Lib/pty.py Wed Nov 12 10:23:44 2014 -0500 +++ b/Lib/pty.py Thu Nov 13 13:00:21 2014 -0500 @@ -136,13 +136,17 @@ rfds, wfds, xfds = select(fds, [], []) if master_fd in rfds: data = master_read(master_fd) - if not data: # Reached EOF. + if data == None: # Don't copy + continue + elif not data: # Reached EOF. fds.remove(master_fd) else: os.write(STDOUT_FILENO, data) if STDIN_FILENO in rfds: data = stdin_read(STDIN_FILENO) - if not data: + if data == None: # Don't copy + continue + elif not data: fds.remove(STDIN_FILENO) else: _writen(master_fd, data)