]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
0ae62838407793c9d4793d7f91cf81ccf41c3908
[thirdparty/openembedded/openembedded-core-contrib.git] /
1 From c6ba19a4cfdb0a5b137b91ef761f654b70776a47 Mon Sep 17 00:00:00 2001
2 From: Alexander Kanavin <alex@linutronix.de>
3 Date: Thu, 16 Sep 2021 16:35:37 +0200
4 Subject: [PATCH] Lib/pty.py: handle stdin I/O errors same way as master I/O
5 errors
6
7 reading stdin can throw the same I/O errors as reading from master fd does,
8 e.g. when running under Yocto's test harness:
9 ======================================================================
10 ERROR: test_spawn_doesnt_hang (test.test_pty.PtyTest)
11 ----------------------------------------------------------------------
12 Traceback (most recent call last):
13 File "/usr/lib/python3.10/test/test_pty.py", line 316, in test_spawn_doesnt_hang
14 pty.spawn([sys.executable, '-c', 'print("hi there")'])
15 File "/usr/lib/python3.10/pty.py", line 181, in spawn
16 _copy(master_fd, master_read, stdin_read)
17 File "/usr/lib/python3.10/pty.py", line 157, in _copy
18 data = stdin_read(STDIN_FILENO)
19 File "/usr/lib/python3.10/pty.py", line 132, in _read
20 return os.read(fd, 1024)
21 OSError: [Errno 5] Input/output error
22
23 So let's treat both channels the same.
24
25 Upstream-Status: Submitted [https://github.com/python/cpython/pull/28388]
26 Signed-off-by: Alexander Kanavin <alex@linutronix.de>
27 ---
28 Lib/pty.py | 5 ++++-
29 1 file changed, 4 insertions(+), 1 deletion(-)
30
31 diff --git a/Lib/pty.py b/Lib/pty.py
32 index 1d97994..fa8821b 100644
33 --- a/Lib/pty.py
34 +++ b/Lib/pty.py
35 @@ -178,7 +178,10 @@ def _copy(master_fd, master_read=_read, stdin_read=_read):
36 i_buf = i_buf[n:]
37
38 if stdin_avail and STDIN_FILENO in rfds:
39 - data = stdin_read(STDIN_FILENO)
40 + try:
41 + data = stdin_read(STDIN_FILENO)
42 + except OSError:
43 + data = b""
44 if not data:
45 stdin_avail = False
46 else: