diff options
author | Micka?l Schoentgen <contact@tiger-222.fr> | 2019-01-07 18:20:59 +0100 |
---|---|---|
committer | Micka?l Schoentgen <contact@tiger-222.fr> | 2019-01-07 18:20:59 +0100 |
commit | 810e049f65b44e06dbfd7c8800750a6230f93b39 (patch) | |
tree | 0532e3686d3260167c974bef44a4f7da69d44aa4 /scripts | |
parent | 867fbbd26114b70d04c5885e1447af1d8acb08df (diff) | |
download | pygments-810e049f65b44e06dbfd7c8800750a6230f93b39.tar.gz |
Fix ResourceWarning: unclosed file
Also uniformize usage of the 'with' contact manager to prevent resource leaks.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/check_sources.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/check_sources.py b/scripts/check_sources.py index db09de42..c0524b6c 100755 --- a/scripts/check_sources.py +++ b/scripts/check_sources.py @@ -185,7 +185,8 @@ def main(argv): print("Checking %s..." % fn) try: - lines = open(fn, 'rb').read().decode('utf-8').splitlines() + with open(fn, 'rb') as f: + lines = f.read().decode('utf-8').splitlines() except (IOError, OSError) as err: print("%s: cannot open: %s" % (fn, err)) num += 1 |