Commit d84f0f9
committed
fix suppress_stdout_stderr not working in Jupyter notebooks
ipykernel replaces sys.stdout/stderr with OutStream objects that store
their own copy of the original file descriptor in _original_stdstream_copy.
This bypasses the dup2 redirect used by suppress_stdout_stderr, so output
still appears even with verbose=False.
Fix by temporarily pointing _original_stdstream_copy at the real fd before
redirecting, and restoring it on exit.
Fixes #8721 parent 1bcc5bc commit d84f0f9
1 file changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
37 | 52 | | |
38 | 53 | | |
39 | 54 | | |
| |||
45 | 60 | | |
46 | 61 | | |
47 | 62 | | |
48 | | - | |
49 | 63 | | |
50 | 64 | | |
51 | 65 | | |
| |||
55 | 69 | | |
56 | 70 | | |
57 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
58 | 78 | | |
59 | 79 | | |
60 | 80 | | |
| |||
0 commit comments