Skip to content

Commit 4e51cb2

Browse files
committed
Merge pull request kubernetes#13090 from mesosphere/finally-undefined
Fix undefined variable f in 'finally' clause of verify-flags-underscore
2 parents 5c0725a + 211fe33 commit 4e51cb2

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

hack/verify-flags-underscore.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,17 @@ def is_binary(pathname):
3636
@author: Trent Mick <[email protected]>
3737
@author: Jorge Orpinel <[email protected]>"""
3838
try:
39-
f = open(pathname, 'r')
40-
CHUNKSIZE = 1024
41-
while 1:
42-
chunk = f.read(CHUNKSIZE)
43-
if '\0' in chunk: # found null byte
44-
return True
45-
if len(chunk) < CHUNKSIZE:
46-
break # done
39+
with open(pathname, 'r') as f:
40+
CHUNKSIZE = 1024
41+
while 1:
42+
chunk = f.read(CHUNKSIZE)
43+
if '\0' in chunk: # found null byte
44+
return True
45+
if len(chunk) < CHUNKSIZE:
46+
break # done
4747
except:
4848
return True
49-
finally:
50-
f.close()
49+
5150
return False
5251

5352
def get_all_files(rootdir):

0 commit comments

Comments
 (0)