Commit 897d20ff authored by Jason Madden's avatar Jason Madden

Add and fix test_ftplib.py and test_asyncore.py for 3.6. See #1050 for a description of failures.

parent 4f9bb1d9
...@@ -156,6 +156,10 @@ ...@@ -156,6 +156,10 @@
``filename`` attribute set. ``filename`` attribute set.
- The :class:`threading.Timer` class is now monkey-patched and can - The :class:`threading.Timer` class is now monkey-patched and can
be joined. be joined.
- :meth:`gevent.ssl.SSLSocket.unwrap` behaves more like the standard
library, including returning a SSLSocket and allowing certain
timeout-related SSL errors to propagate. The added standard
library tests ``test_ftplib.py`` now passes.
1.2.2 (2017-06-05) 1.2.2 (2017-06-05)
================== ==================
......
...@@ -142,6 +142,7 @@ class SSLSocket(socket): ...@@ -142,6 +142,7 @@ class SSLSocket(socket):
server_hostname=None, server_hostname=None,
_session=None, # 3.6 _session=None, # 3.6
_context=None): _context=None):
# pylint:disable=too-many-locals,too-many-statements,too-many-branches # pylint:disable=too-many-locals,too-many-statements,too-many-branches
if _context: if _context:
self._context = _context self._context = _context
...@@ -513,22 +514,32 @@ class SSLSocket(socket): ...@@ -513,22 +514,32 @@ class SSLSocket(socket):
s = self._sslobj.shutdown() s = self._sslobj.shutdown()
break break
except SSLWantReadError: except SSLWantReadError:
# Callers of this method expect to get a socket
# back, so we can't simply return 0, we have
# to let these be raised
if self.timeout == 0.0: if self.timeout == 0.0:
return 0 raise
self._wait(self._read_event) self._wait(self._read_event)
except SSLWantWriteError: except SSLWantWriteError:
if self.timeout == 0.0: if self.timeout == 0.0:
return 0 raise
self._wait(self._write_event) self._wait(self._write_event)
self._sslobj = None self._sslobj = None
# The return value of shutting down the SSLObject is the # The return value of shutting down the SSLObject is the
# original wrapped socket, i.e., _contextawaresock. But that # original wrapped socket passed to _wrap_socket, i.e.,
# object doesn't have the gevent wrapper around it so it can't # _contextawaresock. But that object doesn't have the
# be used. We have to wrap it back up with a gevent wrapper. # gevent wrapper around it so it can't be used. We have to
sock = socket(family=s.family, type=s.type, proto=s.proto, fileno=s.fileno()) # wrap it back up with a gevent wrapper.
s.detach() assert s is self._sock
return sock # In the stdlib, SSLSocket subclasses socket.socket and passes itself
# to _wrap_socket, so it gets itself back. We can't do that, we have to
# pass our subclass of _socket.socket, _contextawaresock.
# So ultimately we should return ourself.
# See test_ftplib.py:TestTLS_FTPClass.test_ccc
return self
else: else:
raise ValueError("No SSL wrapper around " + str(self)) raise ValueError("No SSL wrapper around " + str(self))
......
...@@ -553,7 +553,10 @@ class SSLSocket(socket): ...@@ -553,7 +553,10 @@ class SSLSocket(socket):
if self._sslobj: if self._sslobj:
s = self._sslobj_shutdown() s = self._sslobj_shutdown()
self._sslobj = None self._sslobj = None
return socket(_sock=s) # match _ssl2; critical to drop/reuse here on PyPy # match _ssl2; critical to drop/reuse here on PyPy
# XXX: _ssl3 returns an SSLSocket. Is that what the standard lib does on
# Python 2? Should we do that?
return socket(_sock=s)
else: else:
raise ValueError("No SSL wrapper around " + str(self)) raise ValueError("No SSL wrapper around " + str(self))
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment