[issue45585] Gzipping subprocess output produces invalid .gz file

2021-10-23 Thread Martin Panter
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"

[issue45585] Gzipping subprocess output produces invalid .gz file

2021-10-22 Thread Michael Herrmann
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