From 644f80e7b322e7b485289eec353dec5cdabfe382 Mon Sep 17 00:00:00 2001 From: VirosaLi <2EkF8qUgpNkj> Date: Sat, 5 Dec 2020 21:06:14 -0600 Subject: [PATCH] CLN: use with instead of try finally in io/stata.py --- pandas/io/stata.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 6f296d3c8d92f..853a982536d40 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -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: