1 This patch comes from upstream: http://bugs.python.org/issue26228
2 It has not yet been committed, but seems on track to be, and we need
4 --- Python-3.9.0/Lib/pty.py
5 +++ Python-3.9.0/Lib/pty.py
6 @@ -138,7 +138,7 @@ def _copy(master_fd, master_read=_read,
8 data = master_read(master_fd)
9 if not data: # Reached EOF.
10 - fds.remove(master_fd)
13 os.write(STDOUT_FILENO, data)
14 if STDIN_FILENO in rfds:
15 @@ -155,7 +155,15 @@ def spawn(argv, master_read=_read, stdin
16 sys.audit('pty.spawn', argv)
17 pid, master_fd = fork()
19 - os.execlp(argv[0], *argv)
21 + os.execlp(argv[0], *argv)
23 + # If we wanted to be really clever, we would use
24 + # the same method as subprocess() to pass the error
25 + # back to the parent. For now just dump stack trace.
26 + traceback.print_exc()
30 mode = tty.tcgetattr(STDIN_FILENO)
31 tty.setraw(STDIN_FILENO)
32 @@ -165,6 +173,10 @@ def spawn(argv, master_read=_read, stdin
34 _copy(master_fd, master_read, stdin_read)
36 + # Some OSes never return an EOF on pty, just raise
41 tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)
43 --- Python-3.9.0/Lib/test/test_pty.py
44 +++ Python-3.9.0/Lib/test/test_pty.py
45 @@ -306,7 +306,7 @@ class SmallPtyTests(unittest.TestCase):
47 os.close(write_to_stdin_fd)
49 - # Expect two select calls, the last one will cause IndexError
50 + # Expect two select calls, then a normal return on master EOF
51 pty.select = self._mock_select
52 self.select_rfds_lengths.append(2)
53 self.select_rfds_results.append([mock_stdin_fd, masters[0]])
54 @@ -314,8 +314,7 @@ class SmallPtyTests(unittest.TestCase):
55 # both encountered an EOF before the second select call.
56 self.select_rfds_lengths.append(0)
58 - with self.assertRaises(IndexError):
59 - pty._copy(masters[0])
60 + pty._copy(masters[0])