diff --git a/Libraries/Utility/src/utility/error_handling.py b/Libraries/Utility/src/utility/error_handling.py index a657614ad..8ceff0d32 100644 --- a/Libraries/Utility/src/utility/error_handling.py +++ b/Libraries/Utility/src/utility/error_handling.py @@ -1,6 +1,7 @@ from __future__ import annotations import inspect +import os import sys import traceback import types @@ -293,6 +294,8 @@ def wrapper(*args, **kwargs) -> RT | None: full_message: str = "\n".join(detailed_message) if action == "stderr": + if sys.stderr is None: + sys.stderr = open(os.devnull, "w") # noqa: PTH123, SIM115, PLW1514 # pylint: disable=all print(full_message, sys.stderr) # noqa: T201 elif action == "print": print(full_message) # noqa: T201 diff --git a/Tools/HoloPatcher/src/__main__.py b/Tools/HoloPatcher/src/__main__.py index b1a770730..f94da1481 100644 --- a/Tools/HoloPatcher/src/__main__.py +++ b/Tools/HoloPatcher/src/__main__.py @@ -546,14 +546,14 @@ def handle_exit_button(self): i = 0 while self.task_thread.is_alive(): try: - self.task_thread._stop() # type: ignore[attr-defined] - print("force terminate of install thread succeeded", sys.stdout) # noqa: T201 + self.task_thread._stop() # type: ignore[attr-defined] # pylint: disable=protected-access + print("force terminate of install thread succeeded") except BaseException as e: # pylint: disable=W0718 # noqa: BLE001 self._handle_general_exception(e, "Error using self.install_thread._stop()", msgbox=False) try: if self.task_thread.ident is None: msg = "task ident is None, expected an int." - raise ValueError(msg) + raise ValueError(msg) # noqa: TRY301 self.async_raise(self.task_thread.ident, SystemExit) except BaseException as e: # pylint: disable=W0718 # noqa: BLE001 self._handle_general_exception(e, "Error using async_raise(self.install_thread.ident, SystemExit)", msgbox=False)