Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid infinite loop in path check #97

Open
stratofax opened this issue Aug 29, 2022 · 1 comment
Open

Avoid infinite loop in path check #97

stratofax opened this issue Aug 29, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@stratofax
Copy link
Collaborator

stratofax commented Aug 29, 2022

If the path to the BallotMaker package doesn't include the word "ballotmaker" the program will run an infinite loop. Add a test to break this loop.

From @ion-oset

Suggestion:

  assert path_finder != "/", "Path search reached the file system root."

Or use:

python/importlib_resources

@stratofax stratofax added the bug Something isn't working label Aug 29, 2022
@stratofax stratofax self-assigned this Aug 29, 2022
@ion-oset
Copy link
Collaborator

ion-oset commented Aug 29, 2022

In the immediate term stick to the assertion to avoid the infinite loop. When there's time the correct answer is importlib.resources.files which is explicitly intended to allow access to files from within a package across platforms. This API is available starting from Python 3.9, but exists as a backport using the PyPI package importlib-resources.

See:

I'm happy to pick the PR up for adding importlib-resources when we decide what milestone it's on.

@ion-oset ion-oset self-assigned this Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants