diff --git a/cpplint.py b/cpplint.py index 60b9c2bf25..04fd675767 100755 --- a/cpplint.py +++ b/cpplint.py @@ -6244,7 +6244,8 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): codecs.getwriter('utf8'), 'replace').read().split('\n') else: - lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n') + with codecs.open(filename, 'r', 'utf8', 'replace') as stream: + lines = stream.read().split('\n') # Remove trailing '\r'. # The -1 accounts for the extra trailing blank line we get from split()