Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 12, 2024
1 parent 32cfde7 commit a2a4c6e
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,13 @@ def init_io(self):

if hasattr(sys.stderr, "_original_stdstream_copy"):
for handler in self.log.handlers:
if (isinstance(handler, StreamHandler)
and (buffer := getattr(handler.stream, "buffer"))
and (fileno := getattr(buffer, "fileno"))
and fileno() == sys.stderr._original_stdstream_fd):
self.log.debug(
"Seeing logger to stderr, rerouting to raw filedescriptor."
)
if (
isinstance(handler, StreamHandler)
and (buffer := handler.stream.buffer)
and (fileno := buffer.fileno)
and fileno() == sys.stderr._original_stdstream_fd
):
self.log.debug("Seeing logger to stderr, rerouting to raw filedescriptor.")

handler.stream = TextIOWrapper(
FileIO(
Expand All @@ -534,18 +534,17 @@ def reset_io(self):
"""
stdout, stderr, displayhook = sys.stdout, sys.stderr, sys.displayhook
sys.stdout, sys.stderr, sys.displayhook = self._original_io
if (finish_displayhook := getattr(displayhook, "finish_displayhook",
None)):
if finish_displayhook := getattr(displayhook, "finish_displayhook", None):
finish_displayhook()
if hasattr(sys.stderr, "_original_stdstream_copy"):
for handler in self.log.handlers:
if (isinstance(handler, StreamHandler)
and (buffer := getattr(handler.stream, "buffer"))
and (fileno := getattr(buffer, "fileno"))
and fileno() == sys.stderr._original_stdstream_copy):
self.log.debug(
"Seeing logger to raw filedescriptor, rerouting back to stderr"
)
if (
isinstance(handler, StreamHandler)
and (buffer := handler.stream.buffer)
and (fileno := buffer.fileno)
and fileno() == sys.stderr._original_stdstream_copy
):
self.log.debug("Seeing logger to raw filedescriptor, rerouting back to stderr")

handler.stream = TextIOWrapper(
FileIO(
Expand Down

0 comments on commit a2a4c6e

Please sign in to comment.