File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,7 +60,6 @@ def needs_declaration(fullpath):
6060
6161 if get_declaration (line1 ) or get_declaration (line2 ):
6262 # the file does have an encoding declaration, so trust it
63- infile .close ()
6463 return False
6564
6665 # check the whole file for non utf-8 characters
Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ def looks_like_python(fullpath):
5555 if infile is None :
5656 return False
5757
58- line = infile . readline ()
59- infile .close ()
58+ with infile :
59+ line = infile .readline ()
6060
6161 if binary_re .search (line ):
6262 # file appears to be binary
@@ -76,8 +76,8 @@ def can_be_compiled(fullpath):
7676 if infile is None :
7777 return False
7878
79- code = infile . read ()
80- infile .close ()
79+ with infile :
80+ code = infile .read ()
8181
8282 try :
8383 compile (code , fullpath , "exec" )
You can’t perform that action at this time.
0 commit comments