Nehal Patel added the comment:
In my use case, I was actually trying to stream a large gzip file from the
cloud directly into subprocess without spilling onto disk or RAM i.e. the code
actually looked something more like:
r, w = os.pipe()
# ... launch a thread to feed r
with gzip.open
New submission from Nehal Patel :
The following code produces incorrect behavior:
with gzip.open("foo.gz") as gz:
res = subprocess.run("cat", stdin=gz, capture_output=True)
the contents of res.stdout are identical to the contents of "foo.gz"
It seems the