zeroconf: Use BadDomainName exception instead of string exceptions stable
authorJavi Merino <cibervicho@gmail.com>
Wed, 23 Jun 2010 10:45:53 +0200
branchstable
changeset 11435 7c58cde598fe
parent 11434 86eea1f97eac
child 11436 45eadf71df22
zeroconf: Use BadDomainName exception instead of string exceptions String exceptions no longer work in python 2.6. Use exception classes instead.
hgext/zeroconf/Zeroconf.py
--- a/hgext/zeroconf/Zeroconf.py	Wed Jun 23 11:53:59 2010 +0200
+++ b/hgext/zeroconf/Zeroconf.py	Wed Jun 23 10:45:53 2010 +0200
@@ -204,6 +204,13 @@
 class BadTypeInNameException(Exception):
 	pass
 
+class BadDomainName(Exception):
+	def __init__(self, pos):
+		Exception.__init__(self, "at position %s" % pos)
+
+class BadDomainNameCircular(BadDomainName):
+	pass
+
 # implementation classes
 
 class DNSEntry(object):
@@ -598,10 +605,10 @@
 					next = off + 1
 				off = ((len & 0x3F) << 8) | ord(self.data[off])
 				if off >= first:
-					raise "Bad domain name (circular) at " + str(off)
+					raise BadDomainNameCircular(off)
 				first = off
 			else:
-				raise "Bad domain name at " + str(off)
+				raise BadDomainName(off)
 
 		if next >= 0:
 			self.offset = next