summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--pygments/cmdline.py3
2 files changed, 5 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index f8349a76..ac051d77 100644
--- a/CHANGES
+++ b/CHANGES
@@ -64,6 +64,8 @@ Version 2.13.0
``importlib.metadata`` nor ``importlib_metadata`` is found, but it
will be slower.
+- Silently ignore ``BrokenPipeError`` in the command-line interface
+ (#2193).
- The ``HtmlFormatter`` now uses the ``linespans`` attribute for
``anchorlinenos`` if the ``lineanchors`` attribute is unset (#2026).
- The ``highlight``, ``lex`` and ``format`` functions no longer
diff --git a/pygments/cmdline.py b/pygments/cmdline.py
index f25b1e83..1fdf335a 100644
--- a/pygments/cmdline.py
+++ b/pygments/cmdline.py
@@ -638,6 +638,9 @@ def main(args=sys.argv):
try:
return main_inner(parser, argns)
+ except BrokenPipeError:
+ # someone closed our stdout, e.g. by quitting a pager.
+ return 0
except Exception:
if argns.v:
print(file=sys.stderr)