Да, зато лишний класс на какую то херню
from contextlib import suppress
from traceback import print_tb, print_exception
class MySuppress(suppress):
def __init__(self, *exceptions, log_tracing=False):
self.__log_tracing_flag = log_tracing
super(MySuppress, self).__init__(exceptions)
def __exit__(self, exctype, excinst, exctb):
self.__exctb = exctb
if not self.__log_tracing_flag:
self.__exctb = None
print_exception(exctype, excinst, self.__exctb)
return exctype is not None and issubclass(exctype, self._exceptions)
try:
for _ in range(10):
with MySuppress(ZeroDivisionError, log_tracing=True):
a = 1/0
except Exception:
print("halt")
raise