Martin Panter added the comment:

I would fix the documentation to say the underlying stream should do “exact” 
reads and writes, e.g. one that implements or 
write(). In my experience, most APIs in Python’s library assume or require 
this, rather than the “raw” behaviour.

Is it likely that people are passing raw FileIO or similar objects to GzipFile, 
or is this just a theoretical problem?

Also related: In Issue 24291 and Issue 26721, we realized that all the servers 
based on socketserver could unexpectedly do short writes, which was a practical 
bug (not just theoretical). I changed socketserver over to doing exact writes, 
and added a workaround in the wsgiref module to handle partial writes. See 
 for the altered documentation.

Other APIs that come to mind are shutil.copyfileobj() (documentation proposed 
in Issue 24291), and io.TextIOWrapper (documented as requiring BufferedIOBase). 
Also, the bzip and LZMA modules seem equally affected as gzip.

assignee:  -> docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python
stage:  -> needs patch
versions: +Python 3.6, Python 3.7

Python tracker <>
Python-bugs-list mailing list

Reply via email to