aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/asyncio/base_events.py8
-rw-r--r--Lib/asyncio/sslproto.py1
-rw-r--r--Misc/NEWS.d/next/Library/2018-06-04-13-46-39.bpo-33769.D_pxYz.rst2
3 files changed, 8 insertions, 3 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 34cc6252e77..68a1ebe623b 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1097,7 +1097,7 @@ class BaseEventLoop(events.AbstractEventLoop):
if not getattr(transport, '_start_tls_compatible', False):
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()
ssl_protocol = sslproto.SSLProtocol(
@@ -1111,13 +1111,15 @@ class BaseEventLoop(events.AbstractEventLoop):
transport.pause_reading()
transport.set_protocol(ssl_protocol)
- self.call_soon(ssl_protocol.connection_made, transport)
- self.call_soon(transport.resume_reading)
+ conmade_cb = self.call_soon(ssl_protocol.connection_made, transport)
+ resume_cb = self.call_soon(transport.resume_reading)
try:
await waiter
except Exception:
transport.close()
+ conmade_cb.cancel()
+ resume_cb.cancel()
raise
return ssl_protocol._app_transport
diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py
index 8515ec5eebd..fac2ae74e80 100644
--- a/Lib/asyncio/sslproto.py
+++ b/Lib/asyncio/sslproto.py
@@ -399,6 +399,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin,
called with None as its argument.
"""
self._ssl_protocol._abort()
+ self._closed = True
class SSLProtocol(protocols.Protocol):
diff --git a/Misc/NEWS.d/next/Library/2018-06-04-13-46-39.bpo-33769.D_pxYz.rst b/Misc/NEWS.d/next/Library/2018-06-04-13-46-39.bpo-33769.D_pxYz.rst
new file mode 100644
index 00000000000..9a124fafc6d
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-06-04-13-46-39.bpo-33769.D_pxYz.rst
@@ -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.