summaryrefslogtreecommitdiff
path: root/trollius/sslproto.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2015-09-08 22:55:49 +0200
committerVictor Stinner <vstinner@redhat.com>2015-09-08 22:55:49 +0200
commit0727ad2b6d49cd94ea0fb86ef08c8050208b839a (patch)
tree07179220ffd8f0851769b2d271731f2c365621ad /trollius/sslproto.py
parentf25cb291d8439d9f3d44f52811607d3fdb305d1f (diff)
parent8d79c57726e30fd19d5fadf46375853df7895516 (diff)
downloadtrollius-git-0727ad2b6d49cd94ea0fb86ef08c8050208b839a.tar.gz
Merge asyncio into trollius
Diffstat (limited to 'trollius/sslproto.py')
-rw-r--r--trollius/sslproto.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/trollius/sslproto.py b/trollius/sslproto.py
index 707cc6d..1404fd7 100644
--- a/trollius/sslproto.py
+++ b/trollius/sslproto.py
@@ -1,5 +1,4 @@
import collections
-import sys
import warnings
try:
import ssl
@@ -7,6 +6,7 @@ try:
except ImportError: # pragma: no cover
ssl = None
+from . import compat
from . import protocols
from . import transports
from .log import logger
@@ -326,7 +326,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin,
# On Python 3.3 and older, objects with a destructor part of a reference
# cycle are never destroyed. It's not more the case on Python 3.4 thanks
# to the PEP 442.
- if sys.version_info >= (3, 4):
+ if compat.PY34:
def __del__(self):
if not self._closed:
warnings.warn("unclosed transport %r" % self, ResourceWarning)
@@ -623,7 +623,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)
@@ -647,9 +648,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.