Skip to content

🤖 fix: raise RuntimeError instead of panicking on corrupt point data - #74

Merged
dancergraham merged 1 commit into
mainfrom
fix/panic-to-runtime-error
Dec 1, 2026
Merged

dancergraham merged 1 commit into
mainfrom
fix/panic-to-runtime-error

Conversation

@dancergraham

Copy link
Copy Markdown
Owner

Fixes #72.

read_points called .expect() on pointcloud_simple(...) and on each item from the point iterator. A file with a valid header and XML but corrupt or truncated point data therefore raised pyo3_runtime.PanicException (a BaseException, so except Exception missed it) and printed a Rust panic to stderr. Both now raise RuntimeError with the underlying e57 error message, matching the documented behaviour, so no docstring/stub change is needed.

Verified locally (macOS arm64)

  • New test test_corrupt_point_data (generates the corrupt file in tmp_path, no new fixture): fails on main with PanicException: Unable to read next point: Read { desc: "Failed to read data packet buffers", ... }, passes with this change.
  • pytest: 22 passed on 3.15.0 free-threaded (GIL stays disabled) and on 3.14.8 (GIL build).
  • cargo fmt --all --check: clean. cargo clippy --all-targets -- -D warnings: clean.
  • ruff check / ruff format --check on tests/: clean.

Deliberately left alone

🤖 Generated with Claude Code

read_points used .expect() on the point iterator and on pointcloud_simple,
so a file with a valid header but corrupt or truncated point data raised
pyo3_runtime.PanicException, which derives from BaseException and escapes
`except Exception`. Map both errors to RuntimeError as documented.

Fixes #72

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dancergraham
dancergraham marked this pull request as ready for review December 1, 2026 19:19
@dancergraham
dancergraham merged commit 603d208 into main Dec 1, 2026
73 of 83 checks passed
@dancergraham
dancergraham deleted the fix/panic-to-runtime-error branch December 1, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read_points raises PanicException (not RuntimeError) on corrupt point data

1 participant