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 | c7a23b18749d619e3741d59a48ad3575df15b581 (patch) | |
tree | ed5041f2d453b7c5cdb16623b35ba85374dd3543 /scripts/check_sources.py | |
parent | 46bc0596f084b4162c85c8275be6946d23202bf9 (diff) | |
download | pygments-git-c7a23b18749d619e3741d59a48ad3575df15b581.tar.gz |
Fix ResourceWarning: unclosed file
Also uniformize usage of the 'with' contact manager to prevent resource leaks.
Diffstat (limited to 'scripts/check_sources.py')
-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 |