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

@ -60,7 +60,6 @@ def needs_declaration(fullpath):
if get_declaration(line1) or get_declaration(line2):
# the file does have an encoding declaration, so trust it
infile.close()
return False
# check the whole file for non utf-8 characters

View file

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