mirror of https://github.com/k3s-io/k3s
Merge pull request #13090 from mesosphere/finally-undefined
Fix undefined variable f in 'finally' clause of verify-flags-underscorepull/6/head
commit
4e51cb2a86
|
@ -36,18 +36,17 @@ def is_binary(pathname):
|
||||||
@author: Trent Mick <TrentM@ActiveState.com>
|
@author: Trent Mick <TrentM@ActiveState.com>
|
||||||
@author: Jorge Orpinel <jorge@orpinel.com>"""
|
@author: Jorge Orpinel <jorge@orpinel.com>"""
|
||||||
try:
|
try:
|
||||||
f = open(pathname, 'r')
|
with open(pathname, 'r') as f:
|
||||||
CHUNKSIZE = 1024
|
CHUNKSIZE = 1024
|
||||||
while 1:
|
while 1:
|
||||||
chunk = f.read(CHUNKSIZE)
|
chunk = f.read(CHUNKSIZE)
|
||||||
if '\0' in chunk: # found null byte
|
if '\0' in chunk: # found null byte
|
||||||
return True
|
return True
|
||||||
if len(chunk) < CHUNKSIZE:
|
if len(chunk) < CHUNKSIZE:
|
||||||
break # done
|
break # done
|
||||||
except:
|
except:
|
||||||
return True
|
return True
|
||||||
finally:
|
|
||||||
f.close()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_all_files(rootdir):
|
def get_all_files(rootdir):
|
||||||
|
|
Loading…
Reference in New Issue