Skip to content

Raise TypeError instead of panic on doing fetch_tile from striped TIFFs #99

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented May 13, 2025

What I am changing

  • Avoid panic when running .fetch_tile() on a striped TIFF (that does not have tiles).

How I did it

  • Replace .unwrap() with .map_err(|err| PyTypeError::new_err(err.to_string()))
  • Add unit test to ensure TypeError is raised when calling .fetch_tile() on a striped TIFF

How you can test it

  • Run cd python && uv run pytest --verbose or look at CI

Related Issues

Closes #98

@weiji14 weiji14 added the bug Something isn't working label May 13, 2025
@weiji14 weiji14 requested a review from maxrjones May 13, 2025 02:34
@weiji14 weiji14 marked this pull request as ready for review May 13, 2025 02:44
Comment on lines +72 to +76
let tile = ifd
.fetch_tile(x, y, reader.as_ref())
.await
.map_err(|err| PyTypeError::new_err(err.to_string()))?;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd have an error enum with known variants so that we can check specifically for "trying to load a strip tiff as a tiled tiff" and return a Python TypeError for that specific case.

But this is fine for now.

@weiji14 weiji14 merged commit 6b7df90 into main May 13, 2025
6 checks passed
@weiji14 weiji14 deleted the raise_typeerror branch May 13, 2025 20:07
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

Successfully merging this pull request may close these issues.

rust future panicked: unknown error when TIFF contains strips rather than tiles
2 participants