mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
Cleanup findnocoding.py and pysource.py scripts (with infile/infile.close)
This commit is contained in:
parent
98516a6930
commit
a90f311d05
2 changed files with 4 additions and 5 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue