Kaydet (Commit) a90f311d authored tarafından Victor Stinner's avatar Victor Stinner

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

üst 98516a69
......@@ -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
......
......@@ -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")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment