-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-28867: Warn when NamedTemporaryFile is not explicitly closed #1936
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
Conversation
@jdufresne, thanks for your PR! By analyzing the history of the files in this pull request, we identified @brettcannon, @tim-one and @orsenthil to be potential reviewers. |
Added the news entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the following pattern is acceptable:
try:
...
except urllib.error.HTTPError as exc:
exc.close()
Dealing with HTTPError
's fp
attribute shouldn't be the responsibility of the user. It would be better to deal with it in addbase
:
cpython/Lib/urllib/response.py
Line 14 in 99e6c26
class addbase(tempfile._TemporaryFileWrapper): |
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@berkerpeksag Thanks for the review. I'm happy to adjust the PR to meet the request, but I could use a bit of guidance and more detail. The reason I took this approach is due to the comment here: Lines 742 to 745 in 65ecc39
Are you suggesting that the error handler should eagerly close the file? Would doing so be acceptable? |
Ah, good point, thanks. I need to think about it more carefully. While I don't have objections on the idea discussed in the issue, I think we need to find a solution for |
https://bugs.python.org/issue28867