diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-12-07 12:45:07 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-07 12:45:07 (GMT) |
| commit | a85066df9423d381e6b233469b00db55563a9f80 (patch) | |
| tree | eed2998378f50f5f03da9267de31d3fa0c444316 /Lib/asyncio/selector_events.py | |
| parent | 8ce85a31e6987029832f4e33c4716eb513938c57 (diff) | |
| download | cpython-a85066df9423d381e6b233469b00db55563a9f80.zip cpython-a85066df9423d381e6b233469b00db55563a9f80.tar.gz cpython-a85066df9423d381e6b233469b00db55563a9f80.tar.bz2 | |
bpo-37404: Raising value error if an SSLSocket is passed to asyncio functions (GH-16457)
https://bugs.python.org/issue37404
(cherry picked from commit 892f9e0777f262d366d4747a54c33a1c15a49da6)
Co-authored-by: idomic <michael.ido@gmail.com>
Diffstat (limited to 'Lib/asyncio/selector_events.py')
| -rw-r--r-- | Lib/asyncio/selector_events.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index 23bd8ad..c539b5d 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -345,6 +345,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): The maximum amount of data to be received at once is specified by nbytes. """ + if isinstance(sock, ssl.SSLSocket): + raise TypeError("Socket cannot be of type SSLSocket") if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() @@ -378,6 +380,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): The received data is written into *buf* (a writable buffer). The return value is the number of bytes written. """ + if isinstance(sock, ssl.SSLSocket): + raise TypeError("Socket cannot be of type SSLSocket") if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() @@ -415,6 +419,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. """ + if isinstance(sock, ssl.SSLSocket): + raise TypeError("Socket cannot be of type SSLSocket") if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() @@ -451,6 +457,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): This method is a coroutine. """ + if isinstance(sock, ssl.SSLSocket): + raise TypeError("Socket cannot be of type SSLSocket") if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") @@ -508,6 +516,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. """ + if isinstance(sock, ssl.SSLSocket): + raise TypeError("Socket cannot be of type SSLSocket") if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() |
