From 66a0cc567797d3aaf79fd89430dd8bed2a80e4ab Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Tue, 3 Nov 2026 12:48:56 +0100 Subject: [PATCH 1/4] Add test for broken pipe --- tests/test_igzip.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_igzip.py b/tests/test_igzip.py index 6d9cbf5d..f9e28b2d 100644 --- a/tests/test_igzip.py +++ b/tests/test_igzip.py @@ -769,3 +769,11 @@ def test_small_writes_tell_and_flush(): assert decompressor.decompress(output.getvalue()) == b"abcdef" gzip_file.write(b"gh") assert gzip.decompress(output.getvalue()) == b"abcdefgh" + + +@pytest.mark.skipif(sys.platform != "linux", reason="bash required") +def test_no_broken_pipe(): + subprocess.run([ + "bash", "-c", "-e", "-o", "pipefail", + f"{sys.executable} -m isal.igzip -cd {TEST_FILE} | head -n 10"] , + check=True) From 305bc592fd4a35508854faa9f80c76a06e67ec12 Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Tue, 3 Nov 2026 12:51:10 +0100 Subject: [PATCH 2/4] Fix BrokenPipeError --- CHANGELOG.rst | 5 +++++ src/isal/igzip.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 307b330b..7de0e76d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,11 @@ Changelog .. This document is user facing. Please word the changes in such a way .. that users understand how the changes affect the new version. +develop +----------------- ++ Fix BrokenPipeError when piping ``python -m isal.igzip`` into ``head``, + ``less`` or similar programs. + version 1.9.0 ----------------- diff --git a/src/isal/igzip.py b/src/isal/igzip.py index eb9b8042..b18af11c 100644 --- a/src/isal/igzip.py +++ b/src/isal/igzip.py @@ -386,6 +386,9 @@ def main(): try: shutil.copyfileobj(in_file, out_file, args.buffer_size) + except BrokenPipeError: + # Do not throw errors when a pipe to head or less closes. + pass finally: if in_file is not sys.stdin.buffer: in_file.close() From a3f07e32c386bb9da2a4c6b79735a3aa176fb75a Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Tue, 3 Nov 2026 12:55:38 +0100 Subject: [PATCH 3/4] Fix linting --- tests/test_igzip.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_igzip.py b/tests/test_igzip.py index f9e28b2d..457f13f6 100644 --- a/tests/test_igzip.py +++ b/tests/test_igzip.py @@ -773,7 +773,10 @@ def test_small_writes_tell_and_flush(): @pytest.mark.skipif(sys.platform != "linux", reason="bash required") def test_no_broken_pipe(): - subprocess.run([ - "bash", "-c", "-e", "-o", "pipefail", - f"{sys.executable} -m isal.igzip -cd {TEST_FILE} | head -n 10"] , - check=True) + subprocess.run( + [ + "bash", "-c", "-e", "-o", "pipefail", + f"{sys.executable} -m isal.igzip -cd {TEST_FILE} | head -n 10" + ], + check=True + ) From 75d0c6dc0b1fa9e52669ed5221d96e2571f2d2bb Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Tue, 3 Nov 2026 13:13:08 +0100 Subject: [PATCH 4/4] Set version to 1.9.1 --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7de0e76d..d65c0609 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,7 @@ Changelog .. This document is user facing. Please word the changes in such a way .. that users understand how the changes affect the new version. -develop +version 1.9.1 ----------------- + Fix BrokenPipeError when piping ``python -m isal.igzip`` into ``head``, ``less`` or similar programs.