def delete_if_error(path):
    '''If any exception is raised inside the context, delete the file at the
    given path, and allow the exception to continue.'''
    try:
        yield
    except Exception:
        if os.path.exists(path):
            os.remove(path)
        raise
If any exception is raised inside the context, delete the file at the
    given path, and allow the exception to continue.