changeset 42551:8306b6c29add

py3: hack around inconsistency of type of name passed to DNSQuestion I don't like this patch but this is the easiest way I could fix it. There are some callers which pass name which is bytes, some pass name which is str. I just encode() that if that's str. This does makes test-paths.t pass, but I am not confident whether the whole of zeroconf will work on py3 or not. Differential Revision: https://phab.mercurial-scm.org/D6511
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 11 Jun 2019 20:53:14 +0300
parents 683aeef12830
children 4cafbd3b50c6
files contrib/python3-whitelist hgext/zeroconf/Zeroconf.py
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/python3-whitelist	Tue Jun 11 20:48:59 2019 +0300
+++ b/contrib/python3-whitelist	Tue Jun 11 20:53:14 2019 +0300
@@ -518,6 +518,7 @@
 test-pathconflicts-merge.t
 test-pathconflicts-update.t
 test-pathencode.py
+test-paths.t
 test-pending.t
 test-permissions.t
 test-phabricator.t
--- a/hgext/zeroconf/Zeroconf.py	Tue Jun 11 20:48:59 2019 +0300
+++ b/hgext/zeroconf/Zeroconf.py	Tue Jun 11 20:53:14 2019 +0300
@@ -89,6 +89,8 @@
 import time
 import traceback
 
+from mercurial import pycompat
+
 __all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"]
 
 # hook for threads
@@ -270,6 +272,8 @@
     """A DNS question entry"""
 
     def __init__(self, name, type, clazz):
+        if pycompat.ispy3 and isinstance(name, str):
+            name = name.encode('ascii')
         if not name.endswith(".local."):
             raise NonLocalNameException(name)
         DNSEntry.__init__(self, name, type, clazz)