summaryrefslogtreecommitdiff
path: root/pygments/cmdline.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/cmdline.py')
-rw-r--r--pygments/cmdline.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/pygments/cmdline.py b/pygments/cmdline.py
index 7c23ebee..035f8c87 100644
--- a/pygments/cmdline.py
+++ b/pygments/cmdline.py
@@ -371,7 +371,8 @@ def main(args=sys.argv):
infn = args[0]
try:
- code = open(infn, 'rb').read()
+ with open(infn, 'rb') as infp:
+ code = infp.read()
except Exception as err:
print('Error: cannot read infile:', err, file=sys.stderr)
return 1