Patchwork [4,of,5] check-code: switch to opener

login
register
mail settings
Submitter timeless
Date May 11, 2016, 4:12 a.m.
Message ID <ed2dbfec165a0de79c93.1462939969@gcc2-power8.osuosl.org>
Download mbox | patch
Permalink /patch/14990/
State Accepted
Headers show

Comments

timeless - May 11, 2016, 4:12 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1462931079 0
#      Wed May 11 01:44:39 2016 +0000
# Node ID ed2dbfec165a0de79c93d7fa1ea9cb5f36b10c29
# Parent  5a3db5d3f5259541fbf4d5e2aaf7d055e35b5d9a
# EXP-Topic runtests
# Available At bb://timeless/mercurial-crew
#              hg pull bb://timeless/mercurial-crew -r ed2dbfec165a
check-code: switch to opener

Patch

diff -r 5a3db5d3f525 -r ed2dbfec165a contrib/check-code.py
--- a/contrib/check-code.py	Wed May 11 01:39:07 2016 +0000
+++ b/contrib/check-code.py	Wed May 11 01:44:39 2016 +0000
@@ -493,12 +493,11 @@ 
     result = True
 
     try:
-        fp = open(f)
+        with open(f) as fp:
+            pre = post = fp.read()
     except IOError as e:
         print("Skipping %s, %s" % (f, str(e).split(':', 1)[0]))
         return result
-    pre = post = fp.read()
-    fp.close()
 
     for name, match, magic, filters, pats in checks:
         if debug: