diff options
| author | Sergey Shepelev <temotor@gmail.com> | 2017-02-25 13:40:13 +0300 |
|---|---|---|
| committer | Sergey Shepelev <temotor@gmail.com> | 2017-02-25 13:40:13 +0300 |
| commit | 4e775e23f312c386929e0c5e9a9c952c1ec80c45 (patch) | |
| tree | f2e6fc9cf8956570bc4cf8e94dc6c436d3cbe0dd | |
| parent | 78f2ef8a81600d19d6d670803ef73747ab8d81b9 (diff) | |
| download | eventlet-eainodata-393.tar.gz | |
dns: EAI_NODATA was removed from RFC3493 and FreeBSDeainodata-393
If your code depends on EAI_NODATA, run with EVENTLET_DEPRECATED_EAI_NODATA=yes
during transition to EAI_NONAME.
Support for EAI_NODATA will be removed in future versions.
https://github.com/eventlet/eventlet/issues/393
| -rw-r--r-- | eventlet/support/greendns.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/eventlet/support/greendns.py b/eventlet/support/greendns.py index ea0924c..2f1b8c3 100644 --- a/eventlet/support/greendns.py +++ b/eventlet/support/greendns.py @@ -79,8 +79,14 @@ DNS_QUERY_TIMEOUT = 10.0 HOSTS_TTL = 10.0 EAI_EAGAIN_ERROR = socket.gaierror(socket.EAI_AGAIN, 'Lookup timed out') -EAI_NODATA_ERROR = socket.gaierror(socket.EAI_NODATA, 'No address associated with hostname') EAI_NONAME_ERROR = socket.gaierror(socket.EAI_NONAME, 'Name or service not known') +# EAI_NODATA was removed from RFC3493, it's now replaced with EAI_NONAME +# socket.EAI_NODATA is not defined on FreeBSD, probably on some other platforms too. +# https://lists.freebsd.org/pipermail/freebsd-ports/2003-October/005757.html +EAI_NODATA_ERROR = EAI_NONAME_ERROR +if (os.environ.get('EVENTLET_DEPRECATED_EAI_NODATA', '').lower() in ('1', 'y', 'yes') + and hasattr(socket, 'EAI_NODATA')): + EAI_NODATA_ERROR = socket.gaierror(socket.EAI_NODATA, 'No address associated with hostname') def is_ipv4_addr(host): @@ -459,7 +465,7 @@ def _getaddrinfo_lookup(host, family, flags): try: answer = resolve(host, qfamily, False) except socket.gaierror as e: - if e.errno not in (socket.EAI_AGAIN, socket.EAI_NODATA): + if e.errno not in (socket.EAI_AGAIN, EAI_NONAME_ERROR.errno, EAI_NODATA_ERROR.errno): raise err = e else: |
