Commit 07b2613
g97iulio1609
fix: use os.dup() to prevent stdio transport from closing real stdin/stdout
When stdio_server() wraps sys.stdin.buffer / sys.stdout.buffer in
TextIOWrapper, closing or GC'ing the wrapper also closes the
underlying buffer, making sys.stdin/sys.stdout unusable after
the server exits.
Use os.dup() to duplicate the file descriptors before wrapping,
so the wrappers own independent descriptors that can be safely
closed without affecting the original stdio handles.
Fixes #19331 parent 62575ed commit 07b2613
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| |||
0 commit comments