[New-bugs-announce] [issue20951] SSLSocket.send() returns 0 for non-blocking socket

Nikolaus Rath report at bugs.python.org
Sun Mar 16 22:16:31 CET 2014


New submission from Nikolaus Rath:

When using non-blocking operation, the SSLSocket.send method returns 0 if no data can be sent at this point.

This is counterintuitive, because in the same situation (write to non-blocking socket that isn't ready for IO):

 * A regular (non-SSL) socket raises BlockingIOError
 * libc's send(2) does not return 0, but -EAGAIN or -EWOULDBLOCK.
 * OpenSSL's ssl_write does not return 0, but returns an SSL_ERROR_WANT_WRITE error
 * The ssl module's documentation describes the SSLWantWrite exception as "A subclass of SSLError raised by a non-blocking SSL socket when trying to read or write data, but more data needs to be sent on the underlying TCP transport before the request can be fulfilled."
 * Consistent with that, trying to *read* from a non-blocking SSLSocket when no data is ready raises SSLWantRead, instead of returning zero.

This behavior also makes it more complicated to write code that works with both SSLSockets and regular sockets.


Since the current behavior undocumented at best (and contradicting the documentation at worst), can we change this in Python 3.5?

----------
components: Library (Lib)
messages: 213759
nosy: christian.heimes, giampaolo.rodola, janssen, nikratio, pitrou
priority: normal
severity: normal
status: open
title: SSLSocket.send() returns 0 for non-blocking socket
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20951>
_______________________________________


More information about the New-bugs-announce mailing list