Repository navigation
vector: close files and pipes in v.rast.stats, v.db.*, v.report and v.in.e00 - #8126
Closed
abhinav-phi wants to merge 1 commit into
Closed
abhinav-phi wants to merge 1 commit into
abhinav-phi wants to merge 1 commit into
Conversation
….in.e00 Close gs.pipe_command() stdout and the /dev/null handles these scripts open, so running them with PYTHONDEVMODE=1 no longer reports ResourceWarning. The unused nuldev in v.rast.stats is removed with its os import.
Member
|
Testing against grass 7.8 is not valid at all. It’s really really old and different than the state we are now, code quality-wise |
This was referenced Nov 2, 2026
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
Close files and pipes that these vector tools open and never close:
v.rast.stats: close thegs.pipe_command()stdout inget_nr_of_categories()andperform_stats(); remove the unusednuldevand itsosimport.v.db.droptable: use a context manager for the/dev/nullhandle.v.db.univar,v.db.reconnect.all: close the module-level/dev/nullhandle in afinally.v.report: close the fourgs.pipe_command()stdouts and the/dev/nullhandle.v.in.e00: close the/dev/nullhandle after use.Motivation and context
Part of #8122. With
PYTHONDEVMODE=1these tools report unclosed files and pipes.How has this been tested?
The reproducers from #8122, run with
PYTHONDEVMODE=1:v.rast.stats: before the changev.rast.stats.py:212: ResourceWarning: unclosed file <_io.BufferedReader name=5>plus a/dev/nullwarning; after the change neither, and ther_averagecolumn is still created.v.db.droptable: beforev.db.droptable.py:125: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' ...>; after the change no warning.Tested against GRASS 7.8 from the system package because this machine cannot build main (needs GDAL 3.7+, has 3.4). The changed code paths are version independent.
Types of changes
Checklist
AI assistance was used to prepare this change and the test results above.