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
A file is not properly closed by webbrowser._invoke #59652
Comments
webbrowser._invoke opens /dev/null, never closes it and a warning is I'm attaching a patch. |
Thanks. Is this warning printed by the webbrowser unit tests? If not can you see a way to add one that does? |
The warning is printed by the file object when it closes itself in __del__: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='r+' encoding='UTF-8'> There isn't much to test, or is there? |
To clarify, I discovered this when I was simply running webbrowser.open |
Are there any webbrowser unit tests? (this could probably use the new subprocess.DEVNULL constant in 3.3) |
@anton: That's what I was guessing. If we had a unit test in test_webbrowser that did the same thing, we'd have seen the resource warning when running the tests and fixed it. However, it looks like there aren't *any* tests for webbrowser, not even in test_sundry (which just makes sure modules without tests are importable). So adding a test that will trigger this resource warning requires setting up a test_webbrowser file first, even before we get to the problem of how to test something that wants to start up a web browser...(but that should be solvable with unittest.mock, I think). |
Adding a patch that uses subprocess.DEVNULL instead. Writing tests for webbrowser should be a separate issue, right? |
You could do it either way. Normally we prefer to have a test along with any fix; in this case adding a test involves adding the test module as well, but it is not different in principle. If you want to work on it and prefer to have it as a separate issue that's fine, we'll just make the test issue dependent on this one. |
An updated patch with the same issue fixed in Konqueror class. |
Added tests in bpo-15557. |
New changeset 901c790e4417 by R David Murray in branch 'default': New changeset 5da3b2df38b3 by R David Murray in branch 'default': |
Thanks, Anton. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: