lock: encode result of gethostname into a bytestring
authorAugie Fackler <augie@google.com>
Sun, 12 Mar 2017 03:28:50 -0400
changeset 31375 d57aa655ce97
parent 31374 d30fb3de4b40
child 31376 3690c75f4d1e
lock: encode result of gethostname into a bytestring
mercurial/lock.py
--- a/mercurial/lock.py	Sun Mar 12 12:56:12 2017 -0700
+++ b/mercurial/lock.py	Sun Mar 12 03:28:50 2017 -0400
@@ -15,6 +15,7 @@
 import warnings
 
 from . import (
+    encoding,
     error,
     pycompat,
     util,
@@ -27,7 +28,8 @@
     confidence. Typically it's just hostname. On modern linux, we include an
     extra Linux-specific pid namespace identifier.
     """
-    result = socket.gethostname()
+    result = socket.gethostname().encode(
+        pycompat.sysstr(encoding.encoding), 'replace')
     if pycompat.sysplatform.startswith('linux'):
         try:
             result += '/%x' % os.stat('/proc/self/ns/pid').st_ino