Mercurial > hg
changeset 11435:7c58cde598fe stable
zeroconf: Use BadDomainName exception instead of string exceptions
String exceptions no longer work in python 2.6. Use exception classes
instead.
author | Javi Merino <cibervicho@gmail.com> |
---|---|
date | Wed, 23 Jun 2010 10:45:53 +0200 |
parents | 86eea1f97eac |
children | 45eadf71df22 |
files | hgext/zeroconf/Zeroconf.py |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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