Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly close files #104

Closed
nedbat opened this issue Jan 6, 2011 · 2 comments
Closed

Explicitly close files #104

nedbat opened this issue Jan 6, 2011 · 2 comments
Labels
bug Something isn't working

Comments

@nedbat
Copy link
Owner

nedbat commented Jan 6, 2011

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.


@nedbat
Copy link
Owner Author

nedbat commented Jan 7, 2011

Brett, thanks, I should have known this, having made these very same changes to Cog when porting to Jython. The patch looks great, but I won't get to applying it for a few days...

@nedbat
Copy link
Owner Author

nedbat commented Jan 30, 2011

Fixed in <<changeset 03498ff6127f (bb)>>, thanks Brett!

@nedbat nedbat closed this as completed Jan 30, 2011
@nedbat nedbat added major bug Something isn't working labels Jun 23, 2018
agronholm added a commit to agronholm/coveragepy that referenced this issue Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant