core: don't reconfigure stdout if it's fake (#5020)

This commit is contained in:
black-sliver
2025-05-21 23:22:55 +00:00
committed by GitHub
parent defdf34e60
commit 3b8450036a

View File

@@ -540,6 +540,7 @@ def init_logging(name: str, loglevel: typing.Union[str, int] = logging.INFO,
if add_timestamp:
stream_handler.setFormatter(formatter)
root_logger.addHandler(stream_handler)
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
# Relay unhandled exceptions to logger.