From: Nathan Henrie Date: Sat, 14 May 2016 21:10:52 +0000 (-0600) Subject: Add compatibility with BlockingIOError for Python3 X-Git-Tag: v1.14.0~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49e2af09695445bef4b57601372df64f9b93f9a5;p=thirdparty%2Fdnspython.git 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. --- 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