From 211fe33f40a865f3341da9f94bdea39cc76cc486 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Mon, 24 Aug 2015 15:01:56 +0200 Subject: [PATCH] Fix undefined variable f in 'finally' clause of verify-flags-underscore.py --- hack/verify-flags-underscore.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hack/verify-flags-underscore.py b/hack/verify-flags-underscore.py index af86f97d9ba..56f443a595e 100755 --- a/hack/verify-flags-underscore.py +++ b/hack/verify-flags-underscore.py @@ -36,18 +36,17 @@ def is_binary(pathname): @author: Trent Mick @author: Jorge Orpinel """ try: - f = open(pathname, 'r') - CHUNKSIZE = 1024 - while 1: - chunk = f.read(CHUNKSIZE) - if '\0' in chunk: # found null byte - return True - if len(chunk) < CHUNKSIZE: - break # done + with open(pathname, 'r') as f: + CHUNKSIZE = 1024 + while 1: + chunk = f.read(CHUNKSIZE) + if '\0' in chunk: # found null byte + return True + if len(chunk) < CHUNKSIZE: + break # done except: return True - finally: - f.close() + return False def get_all_files(rootdir):