Explicitly close files · Issue #104 · nedbat/coveragepy (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Description
Originally reported by Brett Cannon (Bitbucket: brettcannon, GitHub: brettcannon)
There are three places in coverage.py where a file is simply opened and read from in a single line, e.g., open(file_path)read()
. While technically valid, it does rely somewhat on CPython semantics of refcounting; other VMs might not close the open file quickly. It also triggers ResourceWarnings in Python 3.2 when run under development settings.
A patch is attached which adds try/finally blocks to explicitly close files.
- Bitbucket: https://bitbucket.org/ned/coveragepy/issue/104
- This issue had attachments: close_files.diff. See the original issue for details.