Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Lib/asyncio/selector_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ async def sock_recv(self, sock, n):
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()
Expand Down Expand Up @@ -378,6 +380,8 @@ async def sock_recv_into(self, sock, buf):
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()
Expand Down Expand Up @@ -415,6 +419,8 @@ async def sock_sendall(self, sock, data):
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()
Expand Down Expand Up @@ -451,6 +457,8 @@ async def sock_connect(self, sock, address):

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")

Expand Down Expand Up @@ -508,6 +516,8 @@ async def sock_accept(self, sock):
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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:mod:`asyncio` now raises :exc:`TyperError` when calling incompatible methods
with an :class:`ssl.SSLSocket` socket. Patch by Ido Michael.