diff Tools/scripts/pysource.py @ 78376:8ace059cdffd

Cleanup findnocoding.py and pysource.py scripts (with infile/infile.close)
author Victor Stinner <victor.stinner@gmail.com>
date Thu, 02 Aug 2012 00:05:41 +0200
parents 67d36e8ddcfc
children
line wrap: on
line diff
--- a/Tools/scripts/pysource.py	Wed Aug 01 20:12:51 2012 +0200
+++ b/Tools/scripts/pysource.py	Thu Aug 02 00:05:41 2012 +0200
@@ -55,8 +55,8 @@
     if infile is None:
         return False
 
-    line = infile.readline()
-    infile.close()
+    with infile:
+        line = infile.readline()
 
     if binary_re.search(line):
         # file appears to be binary
@@ -76,8 +76,8 @@
     if infile is None:
         return False
 
-    code = infile.read()
-    infile.close()
+    with infile:
+        code = infile.read()
 
     try:
         compile(code, fullpath, "exec")