diff options
author | Georg Brandl <georg@python.org> | 2022-07-30 09:19:24 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2022-07-30 10:54:28 +0200 |
commit | 53667339e5f32f6d6a3edce7797c815d34395b51 (patch) | |
tree | e9e3a384b5ca10dcbe1a9b181d39b3103a0a90ae | |
parent | aaca62dab28d4924651e2cf3a6fce872ab522628 (diff) | |
download | pygments-git-53667339e5f32f6d6a3edce7797c815d34395b51.tar.gz |
cmdline: silently ignore ``BrokenPipeError``
This has come up a few times, and I see no good reason to catch
and report this error.
Fixes #2193
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | pygments/cmdline.py | 3 |
2 files changed, 5 insertions, 0 deletions
@@ -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) |