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 <rep...@bugs.python.org>
<http://bugs.python.org/issue20951>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to