I'd like to hear some more opinions on http://bugs.python.org/issue20951. I think the possible courses of action are:
1. Document the current behavior.
This has the drawback that (a) it still remains rather counterintuitive, and (b) one still needs extra code to distinguish between a zero-return because the write would block, and a zero-return because the peer has closed the connection.
I'm not sure about the best way to do this check. I would probably try to run select() on the underlying raw socket. Is there a better way?
2. Change the behavior immediately, potentially breaking some applications that worked around it, but unbreaking others that relied on the documented behavior.
3. Deprecate the current behavior, and introduce a transition period where the new behavior is controlled by a flag.
Drawbacks: no direct breakage of anything, but additional complexity may indirectly cause bugs.