assert isinstance(exc_value, NameError) # find most recent frame if tb is None: return None while tb.tb_next is not None: tb = tb.tb_next frame = tb.tb_frame d ...