Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 211fe33

Browse files
committed
Fix undefined variable f in 'finally' clause of verify-flags-underscore.py
1 parent 8800450 commit 211fe33

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

hack/verify-flags-underscore.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,17 @@ def is_binary(pathname):
3636
@author: Trent Mick <TrentM@ActiveState.com>
3737
@author: Jorge Orpinel <jorge@orpinel.com>"""
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)