From 49e2af09695445bef4b57601372df64f9b93f9a5 Mon Sep 17 00:00:00 2001 From: Nathan Henrie Date: Sat, 14 May 2016 15:10:52 -0600 Subject: [PATCH] Add compatibility with BlockingIOError for Python3 Fixes rthalley/dnspython#156 At least in Python3.5, BlockingIOError is not subscriptable. Its `.errno` attribute seems to be able to provide the necessary information. --- dns/query.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dns/query.py b/dns/query.py index cfa3f172..841dff4f 100644 --- a/dns/query.py +++ b/dns/query.py @@ -292,9 +292,12 @@ def _connect(s, address): s.connect(address) except socket.error: (ty, v) = sys.exc_info()[:2] - if v[0] != errno.EINPROGRESS and \ - v[0] != errno.EWOULDBLOCK and \ - v[0] != errno.EALREADY: + + if hasattr(v, 'errno'): + v_err = v.errno + else: + v_err = v[0] + if v_err not in [errno.EINPROGRESS, errno.EWOULDBLOCK, errno.EALREADY]: raise v -- 2.47.3