Skip to content

Commit

Permalink
Close open files in TextFileReader upon StopIteration
Browse files Browse the repository at this point in the history
  • Loading branch information
agraboso committed Aug 10, 2016
1 parent 6592c73 commit 3fa7d25
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,11 @@ def _clean_options(self, options, engine):
return result, engine

def __next__(self):
return self.get_chunk()
try:
return self.get_chunk()
except StopIteration:
self.close()
raise

def _make_engine(self, engine='c'):
if engine == 'c':
Expand Down

0 comments on commit 3fa7d25

Please sign in to comment.