mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-22 17:00:25 +00:00
replace bare excepts with ones catching StandardError
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3181 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
34af233721
commit
70fedc052c
5 changed files with 13 additions and 13 deletions
|
|
@ -65,11 +65,11 @@ def af_for_address(text):
|
|||
try:
|
||||
junk = linkcheck.dns.ipv4.inet_aton(text)
|
||||
return AF_INET
|
||||
except:
|
||||
except StandardError:
|
||||
try:
|
||||
junk = linkcheck.dns.ipv6.inet_aton(text)
|
||||
return AF_INET6
|
||||
except:
|
||||
except StandardError:
|
||||
raise ValueError
|
||||
|
||||
def inet_ntop(family, address):
|
||||
|
|
|
|||
|
|
@ -749,7 +749,7 @@ class _TextReader(object):
|
|||
raise linkcheck.dns.exception.DNSSyntaxError
|
||||
except linkcheck.dns.exception.DNSSyntaxError:
|
||||
raise linkcheck.dns.exception.DNSSyntaxError
|
||||
except:
|
||||
except StandardError:
|
||||
rdclass = linkcheck.dns.rdataclass.IN
|
||||
# Type
|
||||
rdtype = linkcheck.dns.rdatatype.from_text(token[1])
|
||||
|
|
@ -781,7 +781,7 @@ class _TextReader(object):
|
|||
raise linkcheck.dns.exception.DNSSyntaxError
|
||||
except linkcheck.dns.exception.DNSSyntaxError:
|
||||
raise linkcheck.dns.exception.DNSSyntaxError
|
||||
except:
|
||||
except StandardError:
|
||||
ttl = 0
|
||||
# Class
|
||||
try:
|
||||
|
|
@ -794,7 +794,7 @@ class _TextReader(object):
|
|||
rdclass = self.zone_rdclass
|
||||
except linkcheck.dns.exception.DNSSyntaxError:
|
||||
raise linkcheck.dns.exception.DNSSyntaxError
|
||||
except:
|
||||
except StandardError:
|
||||
rdclass = linkcheck.dns.rdataclass.IN
|
||||
# Type
|
||||
rdtype = linkcheck.dns.rdatatype.from_text(token[1])
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ def udp(q, where, timeout=None, port=53, af=None, source=None, source_port=0):
|
|||
if af is None:
|
||||
try:
|
||||
af = linkcheck.dns.inet.af_for_address(where)
|
||||
except:
|
||||
except StandardError:
|
||||
af = linkcheck.dns.inet.AF_INET
|
||||
if af == linkcheck.dns.inet.AF_INET:
|
||||
destination = (where, port)
|
||||
|
|
@ -188,7 +188,7 @@ def tcp(q, where, timeout=None, port=53, af=None, source=None, source_port=0):
|
|||
if af is None:
|
||||
try:
|
||||
af = linkcheck.dns.inet.af_for_address(where)
|
||||
except:
|
||||
except StandardError:
|
||||
af = linkcheck.dns.inet.AF_INET
|
||||
if af == linkcheck.dns.inet.AF_INET:
|
||||
destination = (where, port)
|
||||
|
|
@ -275,7 +275,7 @@ def xfr(where, zone, rdtype=linkcheck.dns.rdatatype.AXFR, rdclass=linkcheck.dns.
|
|||
if af is None:
|
||||
try:
|
||||
af = linkcheck.dns.inet.af_for_address(where)
|
||||
except:
|
||||
except StandardError:
|
||||
af = linkcheck.dns.inet.AF_INET
|
||||
if af == linkcheck.dns.inet.AF_INET:
|
||||
destination = (where, port)
|
||||
|
|
|
|||
|
|
@ -76,13 +76,13 @@ class TestName (unittest.TestCase):
|
|||
for t in good:
|
||||
try:
|
||||
n = linkcheck.dns.name.from_text(t)
|
||||
except:
|
||||
except StandardError:
|
||||
self.fail("good test '%s' raised an exception" % t)
|
||||
for t in bad:
|
||||
caught = False
|
||||
try:
|
||||
n = linkcheck.dns.name.from_text(t)
|
||||
except:
|
||||
except StandardError:
|
||||
caught = True
|
||||
if not caught:
|
||||
self.fail("bad test '%s' did not raise an exception" % t)
|
||||
|
|
|
|||
|
|
@ -598,14 +598,14 @@ class _MasterReader(object):
|
|||
raise linkcheck.dns.exception.DNSSyntaxError
|
||||
except linkcheck.dns.exception.DNSSyntaxError:
|
||||
raise linkcheck.dns.exception.DNSSyntaxError
|
||||
except:
|
||||
except StandardError:
|
||||
rdclass = self.zone.rdclass
|
||||
if rdclass != self.zone.rdclass:
|
||||
raise linkcheck.dns.exception.DNSSyntaxError, "RR class is not zone's class"
|
||||
# Type
|
||||
try:
|
||||
rdtype = linkcheck.dns.rdatatype.from_text(token[1])
|
||||
except:
|
||||
except StandardError:
|
||||
raise linkcheck.dns.exception.DNSSyntaxError, \
|
||||
"unknown rdatatype '%s'" % token[1]
|
||||
n = self.zone.nodes.get(name)
|
||||
|
|
@ -619,7 +619,7 @@ class _MasterReader(object):
|
|||
# Catch and reraise.
|
||||
(ty, va) = sys.exc_info()[:2]
|
||||
raise ty, va
|
||||
except:
|
||||
except StandardError:
|
||||
# All exceptions that occur in the processing of rdata
|
||||
# are treated as syntax errors. This is not strictly
|
||||
# correct, but it is correct almost all of the time.
|
||||
|
|
|
|||
Loading…
Reference in a new issue