Skip to content

Commit

Permalink
CLN: use with instead of try finally in io/stata.py (#38326)
Browse files Browse the repository at this point in the history
Co-authored-by: VirosaLi <2EkF8qUgpNkj>
  • Loading branch information
fangchenli authored Dec 8, 2020
1 parent 9534c26 commit 1ba3f3c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1912,11 +1912,8 @@ def read_stata(
if iterator or chunksize:
return reader

try:
data = reader.read()
finally:
reader.close()
return data
with reader:
return reader.read()


def _set_endianness(endianness: str) -> str:
Expand Down

0 comments on commit 1ba3f3c

Please sign in to comment.