Patchwork D11303: zeroconf: fix an issue concatenating bytes and str

login
register
mail settings
Submitter phabricator
Date Aug. 18, 2021, 7 p.m.
Message ID <differential-rev-PHID-DREV-numkza37umixhmqyb2ns-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49617/
State Superseded
Headers show

Comments

phabricator - Aug. 18, 2021, 7 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `bytes(length)` doesn't do what we want, so use `str`.
  
  There appear to be a ton more issues in this extension, including:
  
  - globals()[b'_GLOBAL_DONE'] using bytes as the key
  - `__author__` and similar using bytes
  - `BadDomainName` is feeding bytes to the Exception constructor
  - DNSRecord.toString() has the wrong signature (should be str, not bytes)

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  hgext/zeroconf/Zeroconf.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, 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
@@ -770,7 +770,7 @@ 
 
     def writeString(self, value, length):
         """Writes a string to the packet"""
-        format = b'!' + str(length) + b's'
+        format = '!' + str(length) + 's'
         self.data.append(struct.pack(format, value))
         self.size += length