[PATCH 5 of 5] py3: convert popen() command arguments in hgclient to str on Windows

Matt Harbison mharbison72 at gmail.com
Tue Dec 18 01:56:11 EST 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1545112472 18000
#      Tue Dec 18 00:54:32 2018 -0500
# Node ID 932ed8a051de1d7ef7aee5af66395b48080f17b3
# Parent  6de48fd4e5d322f05986427e1dcce150bbf32e47
py3: convert popen() command arguments in hgclient to str on Windows

This fixes test-commandserver.t and test-keyword.t, which was previously
complaining

        TypeError("a bytes-like object is required, not 'str'")

diff --git a/contrib/hgclient.py b/contrib/hgclient.py
--- a/contrib/hgclient.py
+++ b/contrib/hgclient.py
@@ -33,7 +33,12 @@ def connectpipe(path=None, extraargs=())
         cmdline += [b'-R', path]
     cmdline.extend(extraargs)
 
-    server = subprocess.Popen(cmdline, stdin=subprocess.PIPE,
+    def tonative(cmdline):
+        if os.name != r'nt':
+            return cmdline
+        return [arg.decode("utf-8") for arg in cmdline]
+
+    server = subprocess.Popen(tonative(cmdline), stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE)
 
     return server


More information about the Mercurial-devel mailing list