Cleanup findnocoding.py and pysource.py scripts (with infile/infile.close)

This commit is contained in:
Victor Stinner 2012-08-02 00:05:41 +02:00
parent 98516a6930
commit a90f311d05
2 changed files with 4 additions and 5 deletions

View file

@ -55,8 +55,8 @@ def looks_like_python(fullpath):
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 @@ def can_be_compiled(fullpath):
if infile is None:
return False
code = infile.read()
infile.close()
with infile:
code = infile.read()
try:
compile(code, fullpath, "exec")