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

Javi Merino cibervicho at gmail.com
Fri Jun 11 06:56:30 CDT 2010


On 11/06/10 13:27, Mads Kiilerich wrote:
> 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
[...]
>> @@ -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)

Thanks, fixed.

# HG changeset patch
# User Javi Merino <cibervicho at gmail.com>
# Date 1276257260 -7200
# Node ID 6bd17dc43674b81580d5ff2393d875dbe6df9ba4
# 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 %d") % off)
                                first = off
                        else:
-                               raise "Bad domain name at " + str(off)
+                               raise util.Abort(_("Bad domain name at %d") % off)
 
                if next >= 0:
                        self.offset = next

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100611/01654cc1/attachment.pgp>


More information about the Mercurial-devel mailing list