summaryrefslogtreecommitdiff
path: root/utils/check_sources.py
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2016-07-07 18:53:34 +0300
committerVille Skyttä <ville.skytta@iki.fi>2016-07-07 18:53:34 +0300
commite8a8be5788fcf761d61d2e584e25a7d08b93cc95 (patch)
tree5f458c979197ef94c9a4a73dd4b04ec5db1de508 /utils/check_sources.py
parent593708a39cda458386b6c7352bebb62df6191af7 (diff)
downloadsphinx-git-e8a8be5788fcf761d61d2e584e25a7d08b93cc95.tar.gz
Handle more file closing with "with"
Diffstat (limited to 'utils/check_sources.py')
-rwxr-xr-xutils/check_sources.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/utils/check_sources.py b/utils/check_sources.py
index 16bc918cb..18d444057 100755
--- a/utils/check_sources.py
+++ b/utils/check_sources.py
@@ -223,11 +223,8 @@ def main(argv):
print("Checking %s..." % fn)
try:
- f = open(fn, 'rb')
- try:
+ with open(fn, 'rb') as f:
lines = list(f)
- finally:
- f.close()
except (IOError, OSError) as err:
print("%s: cannot open: %s" % (fn, err))
num += 1