mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-37404: Raising value error if an SSLSocket is passed to asyncio functions (GH-16457)
https://bugs.python.org/issue37404
This commit is contained in:
parent
969ae7aca8
commit
892f9e0777
2 changed files with 12 additions and 0 deletions
|
@ -348,6 +348,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||||
The maximum amount of data to be received at once is specified by
|
The maximum amount of data to be received at once is specified by
|
||||||
nbytes.
|
nbytes.
|
||||||
"""
|
"""
|
||||||
|
if isinstance(sock, ssl.SSLSocket):
|
||||||
|
raise TypeError("Socket cannot be of type SSLSocket")
|
||||||
if self._debug and sock.gettimeout() != 0:
|
if self._debug and sock.gettimeout() != 0:
|
||||||
raise ValueError("the socket must be non-blocking")
|
raise ValueError("the socket must be non-blocking")
|
||||||
try:
|
try:
|
||||||
|
@ -386,6 +388,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||||
The received data is written into *buf* (a writable buffer).
|
The received data is written into *buf* (a writable buffer).
|
||||||
The return value is the number of bytes written.
|
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:
|
if self._debug and sock.gettimeout() != 0:
|
||||||
raise ValueError("the socket must be non-blocking")
|
raise ValueError("the socket must be non-blocking")
|
||||||
try:
|
try:
|
||||||
|
@ -425,6 +429,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||||
raised, and there is no way to determine how much data, if any, was
|
raised, and there is no way to determine how much data, if any, was
|
||||||
successfully processed by the receiving end of the connection.
|
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:
|
if self._debug and sock.gettimeout() != 0:
|
||||||
raise ValueError("the socket must be non-blocking")
|
raise ValueError("the socket must be non-blocking")
|
||||||
try:
|
try:
|
||||||
|
@ -472,6 +478,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||||
|
|
||||||
This method is a coroutine.
|
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:
|
if self._debug and sock.gettimeout() != 0:
|
||||||
raise ValueError("the socket must be non-blocking")
|
raise ValueError("the socket must be non-blocking")
|
||||||
|
|
||||||
|
@ -533,6 +541,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||||
object usable to send and receive data on the connection, and address
|
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.
|
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:
|
if self._debug and sock.gettimeout() != 0:
|
||||||
raise ValueError("the socket must be non-blocking")
|
raise ValueError("the socket must be non-blocking")
|
||||||
fut = self.create_future()
|
fut = self.create_future()
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
:mod:`asyncio` now raises :exc:`TyperError` when calling incompatible methods
|
||||||
|
with an :class:`ssl.SSLSocket` socket. Patch by Ido Michael.
|
Loading…
Add table
Add a link
Reference in a new issue