changeset 27770:1b8c7d59be43

check-seclevel: use a context manager for file I/O
author Bryan O'Sullivan <bryano@fb.com>
date Tue, 12 Jan 2016 14:28:16 -0800
parents 40bd01be5c25
children 338c9d227a9e
files doc/check-seclevel.py
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/doc/check-seclevel.py	Tue Jan 12 14:27:42 2016 -0800
+++ b/doc/check-seclevel.py	Tue Jan 12 14:28:16 2016 -0800
@@ -107,11 +107,8 @@
         filename = 'stdin'
         doc = sys.stdin.read()
     else:
-        fp = open(filename)
-        try:
+        with open(filename) as fp:
             doc = fp.read()
-        finally:
-            fp.close()
 
     ui.note(('checking input from %s with initlevel %d\n') %
             (filename, initlevel))