]> granicus.if.org Git - python/commitdiff
asyncio: Make sure BaseException is re-raised in SSLProtocol
authorYury Selivanov <yselivanov@sprymix.com>
Wed, 5 Aug 2015 18:06:23 +0000 (14:06 -0400)
committerYury Selivanov <yselivanov@sprymix.com>
Wed, 5 Aug 2015 18:06:23 +0000 (14:06 -0400)
Lib/asyncio/sslproto.py

index e566946e2209755a2d3aa3184913dedae8a05bc0..e5ae49a5df92da6e769ce7f4b676f8196058c232 100644 (file)
@@ -613,7 +613,8 @@ class SSLProtocol(protocols.Protocol):
                 if data:
                     ssldata, offset = self._sslpipe.feed_appdata(data, offset)
                 elif offset:
-                    ssldata = self._sslpipe.do_handshake(self._on_handshake_complete)
+                    ssldata = self._sslpipe.do_handshake(
+                        self._on_handshake_complete)
                     offset = 1
                 else:
                     ssldata = self._sslpipe.shutdown(self._finalize)
@@ -637,9 +638,13 @@ class SSLProtocol(protocols.Protocol):
                 self._write_buffer_size -= len(data)
         except BaseException as exc:
             if self._in_handshake:
+                # BaseExceptions will be re-raised in _on_handshake_complete.
                 self._on_handshake_complete(exc)
             else:
                 self._fatal_error(exc, 'Fatal error on SSL transport')
+            if not isinstance(exc, Exception):
+                # BaseException
+                raise
 
     def _fatal_error(self, exc, message='Fatal error on transport'):
         # Should be called from exception handler only.