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 io.BufferedIOBase.read(size) 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 
<https://docs.python.org/3.5/library/wsgiref.html#wsgiref.handlers.SimpleHandler>
 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 <rep...@bugs.python.org>
<http://bugs.python.org/issue28436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to