jenkins-core-weekly: update to 2.491
[oi-userland.git] / components / python / python39 / patches / 19-pty.patch
blob6125e2c50934a7e0f864ac081d13f830dfda2f15
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
3 it to fix a bug.
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,
7 if master_fd in rfds:
8 data = master_read(master_fd)
9 if not data: # Reached EOF.
10 - fds.remove(master_fd)
11 + return
12 else:
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()
18 if pid == CHILD:
19 - os.execlp(argv[0], *argv)
20 + try:
21 + os.execlp(argv[0], *argv)
22 + except:
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()
27 + finally:
28 + os._exit(1)
29 try:
30 mode = tty.tcgetattr(STDIN_FILENO)
31 tty.setraw(STDIN_FILENO)
32 @@ -165,6 +173,10 @@ def spawn(argv, master_read=_read, stdin
33 try:
34 _copy(master_fd, master_read, stdin_read)
35 except OSError:
36 + # Some OSes never return an EOF on pty, just raise
37 + # an error instead.
38 + pass
39 + finally:
40 if restore:
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):
46 socketpair[1].close()
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])
63 def tearDownModule():