Skip to content

CLN: remove unnecessary close calls and add a few necessary ones #37837

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

Merged
merged 1 commit into from
Nov 15, 2020
Merged

CLN: remove unnecessary close calls and add a few necessary ones #37837

merged 1 commit into from
Nov 15, 2020

Conversation

twoertwein
Copy link
Member

  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

Follow up to #37639. Close file handles as early as possible.

Remove close calls that are already within a try-except/finally block that closes the file handles.

Add close call for read_json when we read the entire content in one go.

Add close call in read_csv when reaching the end of the iterator.

Put to/read_excel in a try-finally block to make sure that file handles are closed even in case of an exception.

@jreback jreback added the IO Data IO issues that don't fit into a more specific label label Nov 14, 2020
@jreback jreback added this to the 1.2 milestone Nov 14, 2020
@jreback
Copy link
Contributor

jreback commented Nov 14, 2020

small comment, ping on green.

@jreback jreback merged commit 342640b into pandas-dev:master Nov 15, 2020
@jreback
Copy link
Contributor

jreback commented Nov 15, 2020

thanks @twoertwein

@twoertwein twoertwein deleted the close branch November 15, 2020 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants