This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Arden
Recipients Arden
Date 2018-07-26.23:54:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
# spawn(argv, master_read=_read, stdin_read=_read)

With stdin_read function it's possible to customize how one can read from stdin, but it makes little sense without stdout counterpart. For example, you cannot use a wrapped ssl socket to forward a terminal over secure connection, because os.write(STDOUT_FILENO, data) is not suitable for ssl sockets.

The proposal is to add stdout_write argument.

diff --git a/ b/
index e841f12..ed4a12f 100644
--- a/
+++ b/
@@ -126,10 +126,10 @@ def _read(fd):
     """Default read function."""
     return, 1024)
-def _copy(master_fd, master_read=_read, stdin_read=_read):
+def _copy(master_fd, master_read=_read, stdin_read=_read, stdout_write=_writen):
     """Parent copy loop.
-            pty master -> standard output   (master_read)
+            pty master -> standard output   (master_read, stdout_write)
             standard input -> pty master    (stdin_read)"""
     fds = [master_fd, STDIN_FILENO]
     while True:
@@ -139,7 +139,7 @@ def _copy(master_fd, master_read=_read, stdin_read=_read):
             if not data:  # Reached EOF.
-                os.write(STDOUT_FILENO, data)
+                stdout_write(STDOUT_FILENO, data)
         if STDIN_FILENO in rfds:
             data = stdin_read(STDIN_FILENO)
             if not data:
@@ -147,7 +147,7 @@ def _copy(master_fd, master_read=_read, stdin_read=_read):
                 _writen(master_fd, data)
-def spawn(argv, master_read=_read, stdin_read=_read):
+def spawn(argv, master_read=_read, stdin_read=_read, stdout_write=_writen):
     """Create a spawned process."""
     if type(argv) == type(''):
         argv = (argv,)
@@ -161,7 +161,7 @@ def spawn(argv, master_read=_read, stdin_read=_read):
     except tty.error:    # This is the same as termios.error
         restore = 0
-        _copy(master_fd, master_read, stdin_read)
+        _copy(master_fd, master_read, stdin_read, stdout_write)
     except OSError:
         if restore:
             tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)
Date User Action Args
2018-07-26 23:54:56Ardensetrecipients: + Arden
2018-07-26 23:54:56Ardensetmessageid: <>
2018-07-26 23:54:56Ardenlinkissue34243 messages
2018-07-26 23:54:56Ardencreate