mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
modernize some modules' code by using with statement around open()
This commit is contained in:
parent
fd6e6cfa29
commit
2f50aaf2ff
14 changed files with 50 additions and 89 deletions
|
@ -384,9 +384,8 @@ class _Printer(object):
|
|||
for filename in self.__files:
|
||||
filename = os.path.join(dir, filename)
|
||||
try:
|
||||
fp = open(filename, "r")
|
||||
data = fp.read()
|
||||
fp.close()
|
||||
with open(filename, "r") as fp:
|
||||
data = fp.read()
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue