class A: pass class MyException(A): def __new__(cls, x): pass def foo(): raise MyException()