repo can be a Repo object, it's not necessarily a path. You probably want 'r = open_repo(repo)' at the beginning of the function and then r.path here.