From d621277feb235e8da2a1e155a21e80f5daf6d892 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Sat, 18 Feb 2017 17:01:08 +0100 Subject: [PATCH] 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 --- swift/common/middleware/cname_lookup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/swift/common/middleware/cname_lookup.py b/swift/common/middleware/cname_lookup.py index 64576cacd3..fdeb7101e8 100644 --- a/swift/common/middleware/cname_lookup.py +++ b/swift/common/middleware/cname_lookup.py @@ -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