Repository navigation
Conversation
echoix
left a comment
There was a problem hiding this comment.
Where and where in the code and time is the file deleted?
|
Re: "Where and where in the code and time is the file deleted?" Short answer: it isn't, by this code. Tracing what actually removes it, through
This isn't a new gap introduced here: it matches the only other precedent for Generated by Claude Code |
On Windows, a file opened via tempfile.NamedTemporaryFile() cannot be reopened by another process while the Python handle is still open, so r.mfilter failed to read the filter file created this way. Write the filter contents to a path from grass.script.tempfile() instead, which does not hold the file open, and drop the @xfail_windows markers this fix should resolve. Extracted and reworked as a standalone change from PR OSGeo#2616 (by Stefan Blumentrath / @ninsbl), which combined this fix with many other Windows-specific testsuite changes and has been open, unrebased, since 2022. Re-derived against current main rather than cherry-picked, because @ninsbl's branch predates unrelated fixes already merged to this same test file (a docstring/variance correction and other @xfail_windows additions), which a direct cherry-pick would have clobbered. This has not been verified on an actual Windows run; CI on this PR should confirm whether the @xfail_windows markers can indeed be removed. Analysis of PR OSGeo#2616 assisted by AI (Claude), including identifying this as an easily isolated, self-contained candidate for its own PR; verify before merging. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
f1d5501 to
cce419a
Compare
|
This landed upstream as OSGeo#7878 and is now on this fork's Generated by Claude Code |
Description
Extracts and reworks one self-contained change out of upstream PR
OSGeo/grass#2616 ("CI: Address
Windows specific issues in testsuite", open since 2022, 35 commits, by
Stefan Blumentrath / @ninsbl) so it can be evaluated on its own. Opened
against this fork, for testing, not upstream.
raster/r.mfilter/testsuite/test_r_mfilter.pycreates its filter-definitiontemp file with
tempfile.NamedTemporaryFile()and keeps it open (via.name) whiler.mfilteropens the same path again. On Windows this secondopen fails, because Windows does not allow reopening a file that another
handle (here, the still-open Python file object) has locked. That's why all
6 tests in this file carry
@xfail_windows. OSGeo#2616 replaces this withgrass.script.tempfile(create=False), which only reserves a unique path (viag.tempfile -d) without holding it open, then writes to it directly.Motivation and context
An AI (Claude) review of OSGeo#2616 in July 2026, and a second one now, flagged
this as the easiest individual piece of that PR to land as its own, minimal
PR: it is confined to one test file, has a well-understood, verifiable root
cause (the double-open bug is exactly what
@xfail_windows's own docstringdescribes), and doesn't depend on any of the PR's other, more invasive
Windows changes.
That said, OSGeo#2616's own diff for this file is not usable as a straight
cherry-pick: it was branched in 2022 and never rebased, so its diff against
current
mainalso reverts changes unrelated to the tempfile fix thatlanded on
mainin the meantime — a docstring correction(
nc_spm_full_v2alphav2->nc_spm_full_v2beta1), tightenedvariancereference values, and trailing-whitespace cleanup. This PR re-implements
just the tempfile fix against current
main, so none of that unrelatedhistory gets clobbered. It also drops
filter.close()(no longer needed,since
filteris now a path string, not a file object) and the@xfail_windowsmarkers themselves, per the instruction inxfail_windows's own docstring: "Once the test is fixed and passing, removethe decorator."
I have not verified this on an actual Windows machine. If the Windows CI job
here still fails, the
@xfail_windowsmarkers should be restored, and theunderlying reasoning re-examined — the AI analysis should not be taken as
proof the fix works, only as a plausible, checkable hypothesis.
How has this been tested?
python3 -m py_compileon the changed file.ruff check --previewandruff format --diff(both clean, ruff 0.15.17to match
.pre-commit-config.yaml).this environment) — relying on this fork's CI to confirm the fix on
Windows and non-regression on Linux/macOS.
Types of changes
functionality to not work as before)
Checklist
pre-defined prefixes
of this project.
tests in this file are what the change fixes and un-xfails.)
Original fix idea from Stefan Blumentrath (@ninsbl) in
OSGeo/grass#2616, reworked here
against current
main. AI-assisted (Claude) analysis and implementation;please verify independently before relying on this, especially the removal
of the
@xfail_windowsmarkers.🤖 Generated with Claude Code
https://claude.ai/code/session_01HjAoKyq8bFN7cnNaZkwtV6
Generated by Claude Code