Skip to content

grass.pygrass: Fix the vector doctests on Windows - #749

Open
echoix wants to merge 3 commits into
mainfrom
vector-sidx-leak
Open

echoix wants to merge 3 commits into
mainfrom
vector-sidx-leak

Conversation

@echoix

@echoix echoix commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Description

Closes the sidx file handle that Vect_open_sidx() left open when a map is opened in update mode, and compares normalized paths in the get_path doctest.

Motivation and context

On Windows test_pygrass_vector_doctests.py failed in two doctests: removing a map after it was opened with rw failed because the sidx file was still open (on other platforms this leaked a file descriptor), and get_path compared a path with slashes to one built by os.path.join().

How has this been tested?

New pytest test that fails without the fix, test_pygrass_vector_doctests.py with the CI dataset (99 tests pass), and the pygrass vector pytest tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • PR title provides summary of the changes and starts with one of the
    pre-defined prefixes
  • My code follows the code style
    of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

AI assistance was used to diagnose the failure and to write the fix and the test.


Generated by Claude Code

Vect_open_sidx() in update mode left the file handle open when the index
was loaded into memory. Vect_save_sidx() then replaced the handle, so
the file stayed open until the process ended. On Windows this made
removing the map fail with 'Unable to delete file .../sidx'.

The new test checks that no handle to the sidx file is left after a map
opened with pygrass in 'rw' mode is closed.

AI assistance was used to diagnose the failure and to write the fix and
the test.
The expected path is built with os.path.join(), which uses backslashes on
Windows, while get_path() substitutes into a path written with slashes.
@echoix

echoix commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

Can you verify that the pytest and the doctest actually run on windows, and that it passes?

echoix commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

Checked in the Windows job log for 27aba9e:


Generated by Claude Code

echoix commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

Verified on Windows with #750, which has only the new test and no fix. test_update_mode_releases_sidx FAILED there (The file ...\sidx_map\sidx was left open after closing the map), and it was the only pytest failure (1 failed, 1896 passed). It passes on this PR (27aba9e). It also fails without the fix on Linux (1 failed, 1940 passed).


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants