class C1: def __del__(self): 1/0 class C2: def __del__(self): try: 1/0 except: raise def func(cls): x = cls() try: try: x.x except AttributeError: del x raise TypeError except Exception as e: print((e, e.__context__)) func(C1) # Context is OK func(C2) # Context is lost