mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
bpo-33769: start_tls: Fix error message; cancel callbacks on error (GH-7403)
In addition to that, mark SSLTransport as "closed" in its "abort()" method to prevent bogus warnings.
This commit is contained in:
parent
e9e3976057
commit
415bc46a78
3 changed files with 8 additions and 3 deletions
|
@ -1097,7 +1097,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
||||||
|
|
||||||
if not getattr(transport, '_start_tls_compatible', False):
|
if not getattr(transport, '_start_tls_compatible', False):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f'transport {self!r} is not supported by start_tls()')
|
f'transport {transport!r} is not supported by start_tls()')
|
||||||
|
|
||||||
waiter = self.create_future()
|
waiter = self.create_future()
|
||||||
ssl_protocol = sslproto.SSLProtocol(
|
ssl_protocol = sslproto.SSLProtocol(
|
||||||
|
@ -1111,13 +1111,15 @@ class BaseEventLoop(events.AbstractEventLoop):
|
||||||
transport.pause_reading()
|
transport.pause_reading()
|
||||||
|
|
||||||
transport.set_protocol(ssl_protocol)
|
transport.set_protocol(ssl_protocol)
|
||||||
self.call_soon(ssl_protocol.connection_made, transport)
|
conmade_cb = self.call_soon(ssl_protocol.connection_made, transport)
|
||||||
self.call_soon(transport.resume_reading)
|
resume_cb = self.call_soon(transport.resume_reading)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await waiter
|
await waiter
|
||||||
except Exception:
|
except Exception:
|
||||||
transport.close()
|
transport.close()
|
||||||
|
conmade_cb.cancel()
|
||||||
|
resume_cb.cancel()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return ssl_protocol._app_transport
|
return ssl_protocol._app_transport
|
||||||
|
|
|
@ -399,6 +399,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin,
|
||||||
called with None as its argument.
|
called with None as its argument.
|
||||||
"""
|
"""
|
||||||
self._ssl_protocol._abort()
|
self._ssl_protocol._abort()
|
||||||
|
self._closed = True
|
||||||
|
|
||||||
|
|
||||||
class SSLProtocol(protocols.Protocol):
|
class SSLProtocol(protocols.Protocol):
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
asyncio/start_tls: Fix error message; cancel callbacks in case of an
|
||||||
|
unhandled error; mark SSLTransport as closed if it is aborted.
|
Loading…
Add table
Add a link
Reference in a new issue