def __exit__(self, ex_type, ex_val, tb):
    if ex_type is VagueThirdPartyError:
        if ex_val.args[0] == 'foobar':
            raise SpecificException('Foobarred!')
if ex_val.args[0] == 'eggs-and-ham':
    return True
if ex_val.args[0] == 'baz':
    return False
Re-assign exception from within a python __exit__ block