Fix cname_lookup/eventlet 0.20+ DNS exceptions

Since version 0.20, eventlet bundle a dnspython version (commit:
52b09becacd23f384cf69ae37d70c893c43e3b13). Since then, catching
exceptions require the full module path.

Closes-Bug: #1656891

Change-Id: Iac6bb974c1a5d084e450057cf5de1eec80ae21a1
This commit is contained in:
Romain LE DISEZ 2017-02-18 17:01:08 +01:00
parent 7f953ce0b9
commit d621277feb

View File

@ -34,8 +34,7 @@ from swift import gettext_ as _
try:
import dns.resolver
from dns.exception import DNSException
from dns.resolver import NXDOMAIN, NoAnswer
import dns.exception
except ImportError:
# catch this to allow docs to be built without the dependency
MODULE_DEPENDENCY_MET = False
@ -60,7 +59,8 @@ def lookup_cname(domain): # pragma: no cover
result = answer.items[0].to_text()
result = result.rstrip('.')
return ttl, result
except (DNSException, NXDOMAIN, NoAnswer):
except (dns.exception.DNSException, dns.resolver.NXDOMAIN,
dns.resolver.NoAnswer):
return 0, None