# HG changeset patch # User Yuya Nishihara # Date 2018-01-27 04:09:49 # Node ID 4b1c04082cdc6fa5e61a5dddf95a14768f506e05 # Parent ed3a7300b7b5a427bdcffefd0c80aab65824bf4b py3: replace "if ispy3" by encoding.strtolocal() diff --git a/mercurial/lock.py b/mercurial/lock.py --- a/mercurial/lock.py +++ b/mercurial/lock.py @@ -30,9 +30,7 @@ def _getlockprefix(): confidence. Typically it's just hostname. On modern linux, we include an extra Linux-specific pid namespace identifier. """ - result = socket.gethostname() - if pycompat.ispy3: - result = result.encode(pycompat.sysstr(encoding.encoding), 'replace') + result = encoding.strtolocal(socket.gethostname()) if pycompat.sysplatform.startswith('linux'): try: result += '/%x' % os.stat('/proc/self/ns/pid').st_ino diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1508,11 +1508,7 @@ class ui(object): ''.join(exconly)) else: output = traceback.format_exception(exc[0], exc[1], exc[2]) - data = r''.join(output) - if pycompat.ispy3: - enc = pycompat.sysstr(encoding.encoding) - data = data.encode(enc, errors=r'replace') - self.write_err(data) + self.write_err(encoding.strtolocal(r''.join(output))) return self.tracebackflag or force def geteditor(self):