[issue3890] ssl.SSLSocket.recv() implementation may not work with non-blocking sockets
Antoine Pitrou
report at bugs.python.org
Sun Mar 21 21:49:42 CET 2010
Antoine Pitrou <pitrou at free.fr> added the comment:
The intuitive explanation seems to be:
- there are some bytes available for reading on the *TCP socket*, therefore asyncore calls the read handler
- however, there are not enough bytes for OpenSSL to actually decrypt any data, which is why we get SSL_ERROR_WANT_READ when trying to read from the *SSL socket*
The following patch seems to fix test_ftplib; any thoughts?
Index: Lib/test/test_ftplib.py
===================================================================
--- Lib/test/test_ftplib.py (révision 79224)
+++ Lib/test/test_ftplib.py (copie de travail)
@@ -293,7 +293,9 @@
try:
return super(SSLConnection, self).send(data)
except ssl.SSLError, err:
- if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN):
+ if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN,
+ ssl.SSL_ERROR_WANT_READ,
+ ssl.SSL_ERROR_WANT_WRITE):
return 0
raise
@@ -301,6 +303,9 @@
try:
return super(SSLConnection, self).recv(buffer_size)
except ssl.SSLError, err:
+ if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
+ ssl.SSL_ERROR_WANT_WRITE):
+ return ''
if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN):
self.handle_close()
return ''
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3890>
_______________________________________
More information about the Python-bugs-list
mailing list