Skip to content

Conversation

@saurabh12nxf
Copy link
Contributor

Description

This PR fixes issue #6879 where v.to.lines crashes with a Python traceback when the input vector has no attribute table on layer 1.

Changes

  • Added try-except blocks around gs.vector_info() calls at lines 65 and 91
  • Catches CalledModuleError and provides user-friendly error messages
  • Module now exits gracefully with clear, actionable error instead of traceback

Testing

Tested in VM with GRASS GIS:
Test 1 - Vector without layer 1 table:

  • Created vector, removed table with v.db.droptable
  • Ran v.to.lines
  • Result: Clear error message instead of traceback ✓
    Test 2 - Normal vector with table:
  • Created vector with attribute table
  • Ran v.to.lines
  • Result: Works normally as before ✓
    Test 3 - Point input:
  • Created point vector
  • Ran v.to.lines (tests line 91 fix)
  • Result: Works normally ✓

Fixes

Fixes #6879

@github-actions github-actions bot added vector Related to vector data processing Python Related code is in Python module labels Jan 7, 2026
@petrasovaa
Copy link
Contributor

I couldn't reproduce the problem. I would prefer a PR solving the issue, not adding more error handling.

@saurabh12nxf
Copy link
Contributor Author

@petrasovaa Thank you for your patience and guidance!

I've updated the PR with the correct fix:

Changes made:

  • ✅ Changed v.db.droptable to use layer 2 instead of layer 1 (line 181)
  • ✅ Updated error message to reflect layer 2 (line 186)
  • ✅ Removed the unreachable outer exception handler

Reverted:

  • ✅ Removed unnecessary error handling around gs.vector_info() calls

The fix now addresses the root cause you identified. The script should work correctly for vectors with or without tables on layer 1.

Thank you for helping me understand the actual issue!

@petrasovaa petrasovaa merged commit d2ee7c1 into OSGeo:main Jan 13, 2026
27 checks passed
@github-actions github-actions bot added this to the 8.5.0 milestone Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module Python Related code is in Python vector Related to vector data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v.to.lines fails with CalledModuleError when input vector has no layer 1 table

2 participants