Patchwork [2,of,4,py3,v2] lock: encode result of gethostname into a bytestring

login
register
mail settings
Submitter Augie Fackler
Date March 12, 2017, 9:51 p.m.
Message ID <81927dc713bc65e5f449.1489355476@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/19240/
State Changes Requested
Headers show

Comments

Augie Fackler - March 12, 2017, 9:51 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1489303730 14400
#      Sun Mar 12 03:28:50 2017 -0400
# Node ID 81927dc713bc65e5f449fbdf4f9e2e966d068e56
# Parent  4455c6cdbf1e9cd524b43c69ecefef819e0b4e30
lock: encode result of gethostname into a bytestring

Patch

diff --git a/mercurial/lock.py b/mercurial/lock.py
--- a/mercurial/lock.py
+++ b/mercurial/lock.py
@@ -15,6 +15,7 @@  import time
 import warnings
 
 from . import (
+    encoding,
     error,
     pycompat,
     util,
@@ -27,7 +28,7 @@  def _getlockprefix():
     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(encoding.encoding, 'replace')
     if pycompat.sysplatform.startswith('linux'):
         try:
             result += '/%x' % os.stat('/proc/self/ns/pid').st_ino