Skip to content

Commit 1ba3f3c

Browse files
authored
CLN: use with instead of try finally in io/stata.py (#38326)
Co-authored-by: VirosaLi <2EkF8qUgpNkj>
1 parent 9534c26 commit 1ba3f3c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

pandas/io/stata.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1912,11 +1912,8 @@ def read_stata(
19121912
if iterator or chunksize:
19131913
return reader
19141914

1915-
try:
1916-
data = reader.read()
1917-
finally:
1918-
reader.close()
1919-
return data
1915+
with reader:
1916+
return reader.read()
19201917

19211918

19221919
def _set_endianness(endianness: str) -> str:

0 commit comments

Comments
 (0)