Код: Выделить всё
class SomeClass:
def __new__(cls):
class ExWithClsInfo(RuntimeError):
def __init__(self, msg: str, *args):
super().__init__(f"{cls.__name__}: {msg}", *args)
obj = super().__new__(cls)
obj.Ex = ExWithClsInfo
return obj
class A(SomeClass):
pass
Код: Выделить всё
a = A()
raise a.Ex("test")
Traceback (most recent call last):
File "", line 1, in
SomeClass.__new__..ExWithClsInfo: A: test
Как мне это очистить, чтобы в обратной трассировке отображался только Someclass.Ex или SomeClass.ExWithClsInfo без .__new__.?
Подробнее здесь: https://stackoverflow.com/questions/798 ... -exception
Мобильная версия