Repository navigation
grass.pygrass: Raise GrassError in c_read_next_line when Vect_read_next_line fails - #7967
Open
bhuvan-somisetty wants to merge 1 commit into
Open
bhuvan-somisetty wants to merge 1 commit into
bhuvan-somisetty wants to merge 1 commit into
Conversation
bhuvan-somisetty
force-pushed
the
fix-7966-pygrass-c_read_next_line
branch
from
September 29, 2026 21:23
bd5584c to
f656ac3
Compare
…xt_line fails In `python/grass/pygrass/vector/geometry.py`, `c_read_next_line` previously executed a bare `raise` when `Vect_read_next_line` returned -1. Because this occurred outside an active exception handler, Python raised a `RuntimeError` indicating no active exception to reraise. Fix this by explicitly raising `GrassError` with an informative error message and add unit tests in `test_geometry.py`. Fixes OSGeo#7966. Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
bhuvan-somisetty
force-pushed
the
fix-7966-pygrass-c_read_next_line
branch
from
September 29, 2026 21:49
f656ac3 to
a64aa47
Compare
Contributor
Author
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.
Description
In
python/grass/pygrass/vector/geometry.py, thec_read_next_linehelper function previously executed a bareraisestatement whenftype == -1(whenlibvect.Vect_read_next_lineencounters a read error or corrupted line). Because this statement was outside any active exception block, Python raisedRuntimeError: No active exception to reraise.This PR replaces the bare
raisewithraise GrassError(msg)to raise an informativeGrassErrorwhen reading the next vector line fails, and adds unit tests topython/grass/pygrass/vector/testsuite/test_geometry.py.Motivation and context
Fixes #7966.
How has this been tested?
Added unit tests in
python/grass/pygrass/vector/testsuite/test_geometry.pytesting thatc_read_next_lineraisesGrassErroronftype == -1andStopIterationonftype == -2. Verified code formatting and lint checks usingruff checkandruff format.Screenshots (if appropriate)
Types of changes
Checklist