summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMicka?l Schoentgen <contact@tiger-222.fr>2019-01-07 18:20:59 +0100
committerMicka?l Schoentgen <contact@tiger-222.fr>2019-01-07 18:20:59 +0100
commit810e049f65b44e06dbfd7c8800750a6230f93b39 (patch)
tree0532e3686d3260167c974bef44a4f7da69d44aa4 /scripts
parent867fbbd26114b70d04c5885e1447af1d8acb08df (diff)
downloadpygments-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-xscripts/check_sources.py3
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