Skip to content

Commit ec85c79

Browse files
committed
ssl: Fix AttributeError('errno')
1 parent 70c332c commit ec85c79

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

uvloop/sslproto.pyx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ cdef class _SSLPipe:
196196
# Drain possible plaintext data after close_notify.
197197
appdata.append(self._incoming.read())
198198
except (ssl_SSLError, ssl_CertificateError) as exc:
199-
errno = <int>exc.errno
199+
errno = <int>getattr(exc, 'errno', 0) # SSL_ERROR_NONE = 0
200200
if errno not in (ssl_SSL_ERROR_WANT_READ, ssl_SSL_ERROR_WANT_WRITE,
201201
ssl_SSL_ERROR_SYSCALL):
202202
if self._state is _DO_HANDSHAKE and self._handshake_cb:
@@ -244,7 +244,7 @@ cdef class _SSLPipe:
244244
if offset < len(view):
245245
offset += self._sslobj.write(view[offset:])
246246
except ssl_SSLError as exc:
247-
errno = <int>exc.errno
247+
errno = <int>getattr(exc, 'errno', 0) # SSL_ERROR_NONE = 0
248248
# It is not allowed to call write() after unwrap() until the
249249
# close_notify is acknowledged. We return the condition to the
250250
# caller as a short write.
@@ -495,8 +495,9 @@ class SSLProtocol(object):
495495
ssldata, appdata = (<_SSLPipe>self._sslpipe).feed_ssldata(data)
496496
except ssl_SSLError as e:
497497
if self._loop.get_debug():
498-
aio_logger.warning('%r: SSL error %s (reason %s)',
499-
self, e.errno, e.reason)
498+
aio_logger.warning('%r: SSL error errno:%s (reason %s)',
499+
self, getattr(e, 'errno', 'missing'),
500+
e.reason)
500501
self._abort()
501502
return
502503

0 commit comments

Comments
 (0)