fix I/O operation on closed file error with CliRunner and echo_via_pager#3482
Conversation
|
Seems like we should be able to keep the single wrapper and override the close method to do nothing in the problematic case. |
| # while text-only streams are yielded as-is. | ||
| if _has_binary_buffer(stream): | ||
| # route stdout and stderr through a thinner wrapper | ||
| is_std = stream is sys.stdout or stream is sys.stderr |
There was a problem hiding this comment.
@Rowlando13 this is a good example of why I think the whole text/binary stream handling in Click is not needed. It's completely bypassed for stdin/stdout here, and all tests still pass. Fairly sure these checks were for Python 2/3 compat, but I didn't have enough time to check it all when I removed most of the compat years ago.
|
After investigating from my initial comment, it does look like we need to wrap the stream returned by |
2cf8e01 to
becbde5
Compare
|
Also needed to make sure |
Also CC @AndreasBackx for the missing tests in #3405 covering #1572 |
Fixes #3449 by adding a thinner version of
MaybeStripAnsithat is not subclassed fromio.TextIOWrapperwhen handlingsys.stdoutandsys.stderrstreams.