Skip to content

misc: close leaked files in m.proj, g.extension, G_debug and an r.in.gdal test - #8127

Closed
abhinav-phi wants to merge 1 commit into
OSGeo:mainfrom
abhinav-phi:misc-close-files
Closed

abhinav-phi wants to merge 1 commit into
OSGeo:mainfrom
abhinav-phi:misc-close-files

Conversation

@abhinav-phi

Copy link
Copy Markdown

Description

  • m.proj: close the input and output files after the conversion.
  • g.extension: close the /dev/null output handle in install_extension_win() and install_extension_std_platforms(); use a context manager for the probe read in fix_newlines().
  • grass.pygrass.modules.interface.env.G_debug(): close GRASS_DEBUG_FILE after each message instead of leaking one handle per call.
  • r.in.gdal testsuite: close the file read in test_r_in_gdal.py.

Motivation and context

Part of #8122. These are the remaining small, independent leaks listed there.

How has this been tested?

  • G_debug(), called three times with GRASS_DEBUG_FILE set and PYTHONDEVMODE=1: before the change one ResourceWarning: unclosed file ... dbg.txt; after the change none.
  • m.proj: the change closes handles after p.wait(); I could not run the reproducer here because GRASS 7.8 does not accept g.proj format=proj4, which current m.proj uses.
  • g.extension: not run (needs an add-on download); the change only closes handles at the end of the two install functions and wraps one open() in with.

Types of changes

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

Checklist

AI assistance was used to prepare this change and the test results above.

…gdal test

Close m.proj input/output files, g.extension /dev/null output and the file opened for each G_debug message. Use a context manager in fix_newlines() and in the r.in.gdal testsuite.
@github-actions github-actions Bot added raster Related to raster data processing Python Related code is in Python libraries module general tests Related to Test Suite misc labels Oct 28, 2026
@echoix

echoix commented Oct 28, 2026

Copy link
Copy Markdown
Member

Again, understand your changes, and do actual useful validations of your work. Grass 7.8 and anything other than the state of your branch is not useful

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

Labels

general libraries misc module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants