Skip to content

Commit 793c770

Browse files
committed
COMPAT: make sure to close state file handles on exception in reading
1 parent c7f37fc commit 793c770

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/io/stata.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ def read_stata(filepath_or_buffer, convert_dates=True,
169169
if iterator or chunksize:
170170
data = reader
171171
else:
172-
data = reader.read()
173-
reader.close()
172+
try:
173+
data = reader.read()
174+
finally:
175+
reader.close()
174176
return data
175177

176178
_date_formats = ["%tc", "%tC", "%td", "%d", "%tw", "%tm", "%tq", "%th", "%ty"]

0 commit comments

Comments
 (0)