This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mherrmann.at
Recipients mherrmann.at
Date 2021-10-23.06:13:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634969637.88.0.109314303688.issue45585@roundup.psfhosted.org>
In-reply-to
Content
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 getting "OSError: Not a gzipped file (b'hi')". I am attaching test.gz.

This appears for me on Debian 10 / Python 3.7 and Debian 11 / Python 3.9. I have not yet tested on other OSs and Python versions.

The reason why I expect the above to work is that the subprocess documentation states that the stdout parameter may be "an existing file object" and that on the other hand the documentation for gzip.open(...) states that it returns a file object.

Maybe this is related to #40885?
History
Date User Action Args
2021-10-23 06:13:57mherrmann.atsetrecipients: + mherrmann.at
2021-10-23 06:13:57mherrmann.atsetmessageid: <1634969637.88.0.109314303688.issue45585@roundup.psfhosted.org>
2021-10-23 06:13:57mherrmann.atlinkissue45585 messages
2021-10-23 06:13:57mherrmann.atcreate