fix: avoid "[PYI-28040:ERROR]" log message when run via pyinstaller

This commit is contained in:
sebthom
2025-04-27 14:34:56 +02:00
parent 7b0774874e
commit 52e1682dba
3 changed files with 19 additions and 6 deletions

View File

@@ -5,14 +5,18 @@ SPDX-ArtifactOfProjectHomePage: https://github.com/Second-Hand-Friends/kleinanze
"""
import sys, traceback
from types import FrameType, TracebackType
from typing import Any, Final
from typing import Final
from . import loggers
LOG:Final[loggers.Logger] = loggers.get_logger(__name__)
def on_exception(ex_type:type[BaseException], ex_value:Any, ex_traceback:TracebackType | None) -> None:
def on_exception(ex_type: type[BaseException] | None, ex_value: BaseException | None, ex_traceback: TracebackType | None) -> None:
if ex_type is None or ex_value is None:
LOG.error("Unknown exception occurred (missing exception info): ex_type=%s, ex_value=%s", ex_type, ex_value)
return
if issubclass(ex_type, KeyboardInterrupt):
sys.__excepthook__(ex_type, ex_value, ex_traceback)
elif loggers.is_debug(LOG) or isinstance(ex_value, (AttributeError, ImportError, NameError, TypeError)):