Martin Panter added the comment:
The subprocess module only uses the file object to get a file handle by calling
the "fileno" method. See Issue 19992 about documenting this. For Python to
compress the output of the child process, you would need a pipe.
Gzip file objects provide the "fileno"
New submission from Michael Herrmann :
Consider the following:
import gzip
import subprocess
with gzip.open('test.gz', 'wb') as f:
subprocess.run(['echo', 'hi'], stdout=f)
with gzip.open('test.gz', 'rb') as f:
print(f.read())
I'd expect "hi" to appear in my console. Instead, I'm gett