Repository navigation
🤖 fix: raise RuntimeError instead of panicking on corrupt point data - #74
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #72.
read_pointscalled.expect()onpointcloud_simple(...)and on each item from the point iterator. A file with a valid header and XML but corrupt or truncated point data therefore raisedpyo3_runtime.PanicException(aBaseException, soexcept Exceptionmissed it) and printed a Rust panic to stderr. Both now raiseRuntimeErrorwith the underlyinge57error message, matching the documented behaviour, so no docstring/stub change is needed.Verified locally (macOS arm64)
test_corrupt_point_data(generates the corrupt file intmp_path, no new fixture): fails onmainwithPanicException: 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 --checkontests/: clean.Deliberately left alone
.unwrap()s inread_points(Array2::from_shape_vec,raw_xml's unwrap after theOkcheck) can't fail.unsafe fnare Release the GIL / detach during read_points and raw_xml #73.🤖 Generated with Claude Code