You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"I/O operation on closed file" error with CliRunner and echo_via_pager under 8.4 #3449
I ran into exactly the same issue when I tried to update click in Fedora Linux. 1 test failed, and 189 ended with errors all with the same error: ValueError: I/O operation on closed file..
Same issue on our side after upgrading click to 8.4, see test output logs.
Looks like a regression introduced by commit c69643b as the new get_pager_file function used in echo_via_pager implementation returns a context manager wrapping a TextIO. So when the wrapped TextIO is sys.stdout, it is automatically closed when exiting the context manager.
Activity
frenzymadness commentedon May 18, 2026
I ran into exactly the same issue when I tried to update click in Fedora Linux. 1 test failed, and 189 ended with errors all with the same error:
ValueError: I/O operation on closed file..anlambert commentedon May 18, 2026
Same issue on our side after upgrading click to 8.4, see test output logs.
Looks like a regression introduced by commit c69643b as the new
get_pager_filefunction used inecho_via_pagerimplementation returns a context manager wrapping aTextIO. So when the wrappedTextIOissys.stdout, it is automatically closed when exiting the context manager.ChrisPappalardo commentedon May 19, 2026
Picking up this issue at pycon2026.
tests: Workaround echo_with_pager regression in click 8.4.0
tests: Workaround echo_with_pager regression in click 8.4.0
kdeldycke commentedon May 22, 2026
For context, this is because #1572 was merged early without tests and the follow up #3405 did not cover this situation.
kdeldycke commentedon May 29, 2026
This fix was not complete. I proposed one at #3533 . @ChrisPappalardo @anlambert @frenzymadness @mschmitzer, can you review and test it?
Do not let the GC close a borrowed `stdout`
Do not let the GC close a borrowed `stdout`