Skip to content

Commit 86c6873

Browse files
committed
make closing of custom stdout and stderr more strict
1 parent e80b5e6 commit 86c6873

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ipykernel/kernelapp.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,11 @@ def reset_io(self):
559559
"w",
560560
)
561561
)
562-
stderr.close()
563-
stdout.close()
562+
if hasattr(sys.stderr, "_original_stdstream_copy"):
563+
stderr.close()
564+
if hasattr(sys.stdout, "_original_stdstream_copy"):
565+
stdout.close()
564566
if self._blackhole:
565-
# already closed by above but no harm calling again
566567
self._blackhole.close()
567568

568569
def patch_io(self):

0 commit comments

Comments
 (0)