check-seclevel: use a context manager for file I/O
authorBryan O'Sullivan <bryano@fb.com>
Tue, 12 Jan 2016 14:28:16 -0800
changeset 27770 1b8c7d59be43
parent 27769 40bd01be5c25
child 27771 338c9d227a9e
check-seclevel: use a context manager for file I/O
doc/check-seclevel.py
--- 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))