Patchwork D6510: py3: add r'' prefixes and do ('%d' % int) instead of str(int)

login
register
mail settings
Submitter phabricator
Date June 11, 2019, 6 p.m.
Message ID <differential-rev-PHID-DREV-7uedxw66pgchxhnk6gs5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/40428/
State Superseded
Headers show

Comments

phabricator - June 11, 2019, 6 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This addresses more failures related to zeroconf on py3.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6510

AFFECTED FILES
  hgext/zeroconf/Zeroconf.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py
--- a/hgext/zeroconf/Zeroconf.py
+++ b/hgext/zeroconf/Zeroconf.py
@@ -535,7 +535,7 @@ 
 
     def readString(self, len):
         """Reads a string of a given length from the packet"""
-        format = '!' + str(len) + 's'
+        format = '!%ds' % len
         length = struct.calcsize(format)
         info = struct.unpack(format,
                              self.data[self.offset:self.offset + length])
@@ -613,7 +613,7 @@ 
 
     def readName(self):
         """Reads a domain name from the packet"""
-        result = ''
+        result = r''
         off = self.offset
         next = -1
         first = off
@@ -625,7 +625,7 @@ 
                 break
             t = len & 0xC0
             if t == 0x00:
-                result = ''.join((result, self.readUTF(off, len) + '.'))
+                result = r''.join((result, self.readUTF(off, len) + r'.'))
                 off += len
             elif t == 0xC0:
                 if next < 0: