Jason Madden added the comment:

I'm sorry, I'm still not following the argument that `write` is likely to 
return nothing. `RawIOBase` and `BufferedIOBase` both document that `write` 
must return the number of written bytes; if you don't return that, you break 
anything that assumes you do, as documented (because both patterns for checking 
if you need to keep looping are both TypeErrors: `written = 0; written += None` 
and `None < len(data)`); and if you ignore the return value, you fail when 
using any `IOBase` object that *isn't* buffered (exactly this case).

But you are definitely right, explicitly checking for None can be done. It adds 
a trivial amount of overhead, but this isn't a production server. The only cost 
is code readability.

Good point about the explicit calls to `flush()`, I thought flush was a no-op 
in some streams, but that's only the case for streams where it doesn't already 
matter.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24291>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to