Skip to content

Close file handles with context managers - #541

Open
ThVerg wants to merge 1 commit into
olofk:mainfrom
ThVerg:fix/unclosed-file-handles
Open

Close file handles with context managers#541
ThVerg wants to merge 1 commit into
olofk:mainfrom
ThVerg:fix/unclosed-file-handles

Conversation

@ThVerg

@ThVerg ThVerg commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

The modelsim and questaformal backends open their generated .tcl and Makefile outputs without closing them (_write_build_rtl_tcl_file never closes; the others close but not exception-safely), which shows up as ResourceWarnings when running the test suite. reporting.py and tools/edatool.py leak read handles the same way (open(...).read()).

This converts all of them to with context managers. The diff in modelsim/questaformal looks large but is almost entirely re-indentation of the method bodies under the with block — no functional change.

Verified: full test suite passes with -W error::ResourceWarning (204 passed), and the golden-file tests confirm generated output is unchanged. Formatted with black 22.3.0.

modelsim and questaformal opened their generated tcl/Makefile outputs
without closing them (or closed them in a non-exception-safe way),
which shows up as ResourceWarnings under pytest. reporting and
tools/edatool leaked read handles the same way.

Convert all of them to with-statements. No functional change; the
test suite passes with -W error::ResourceWarning.
@ThVerg
ThVerg force-pushed the fix/unclosed-file-handles branch from 00dcddc to c5ecd00 Compare July 2, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant