-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
API: ensure read_json closes file handle #49921
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
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.
Looks good to me (easier to review with the "hide whitespace" option)
Nice one, I didn't know about that one. It does indeed makes changes that are mostly changing the indention level easier to review. |
Yeah I don't think this needs a whatsnew entry - leaving open for a bit in case others have comments / disagree |
Could note in the |
fb362d3
to
e93b6da
Compare
Thanks for the comments. I've added a whatsnew entry + updated the PR to also improve the handling of closing files in |
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.
Would it be easy to test that the files handles are closed when an exception is encountered?
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
not sure, maybe serving a malformed file (though haven't checked if that is tested already or maybe caught in the init)? |
error looks unrelated ("ERROR: Could not find a version that satisfies the requirement setuptools==59.2.0") |
Thanks @topper-123. If you have any inspirations on how to test that files are closed on exceptions happy to have a follow up |
Use context manager instead of closing manually with
self.close
to ensure file always closes.Not sure if this should have a whatsnew entry and where.