[PATCH] zeroconf: use util.Abort() instead of deprecated string exceptions

Mads Kiilerich mads at kiilerich.com
Fri Jun 11 06:27:29 CDT 2010


On 06/11/2010 01:22 PM, Javi Merino wrote:
> Hi, string exceptions no longer work in python 2.6 [0]. This patch
> fixes the zeroconf module, which still used them.
>
> [0] http://docs.python.org/whatsnew/2.6.html#deprecations-and-removals
>
> Regards,
> Javi (Vicho)
>
> # HG changeset patch
> # User Javi Merino<cibervicho at gmail.com>
> # Date 1276255042 -7200
> # Node ID a5be2a7ddc75b9ba3838d676ae5feb6cbfd1beb4
> # Parent  5bf46516063236efd8a2646643dba9ad3487a109
> zeroconf: use util.Abort() instead of deprecated string exceptions
>
> String exceptions no longer work in python 2.6. This changeset makes
> zeroconf use the util.Abort() exception instead.
>
> diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py
> --- a/hgext/zeroconf/Zeroconf.py
> +++ b/hgext/zeroconf/Zeroconf.py
> @@ -78,6 +78,8 @@ __author__ = "Paul Scott-Murphy"
>   __email__ = "paul at scott dash murphy dot com"
>   __version__ = "0.12"
>
> +from mercurial.i18n import _
> +from mercurial import util
>   import string
>   import time
>   import struct
> @@ -598,10 +600,10 @@ class DNSIncoming(object):
>                                          next = off + 1
>                                  off = ((len&  0x3F)<<  8) | ord(self.data[off])
>                                  if off>= first:
> -                                       raise "Bad domain name (circular) at " + str(off)
> +                                       raise util.Abort(_("Bad domain name (circular) at " + str(off)))

The parameter should be outside the localization markup - something like
	util.Abort(_("Bad domain name (circular) at %s"), off)

>                                  first = off
>                          else:
> -                               raise "Bad domain name at " + str(off)
> +                               raise util.Abort(_("Bad domain name at " + str(off)))

same

>
>                  if next>= 0:
>                          self.offset = next

/Mads


More information about the Mercurial-devel mailing list