Comments
Patch
@@ -60,11 +60,24 @@
processlock = threading.Lock()
-# subprocess._cleanup can race with any Popen.wait or Popen.poll on py24
-# http://bugs.python.org/issue1731717 for details. We shouldn't be producing
-# zombies but it's pretty harmless even if we do.
-if sys.version_info[1] < 5:
- subprocess._cleanup = lambda: None
+if sys.version_info[0] >= 3:
+ def makebytes(d):
+ if isinstance(d, str):
+ return d.encode('utf-8')
+ return d
+ def makestr(d):
+ if isinstance(d, bytes):
+ return d.decode('utf-8')
+ return d
+else:
+ # subprocess._cleanup can race with any Popen.wait or Popen.poll on py24
+ # http://bugs.python.org/issue1731717 for details. We shouldn't be producing
+ # zombies but it's pretty harmless even if we do.
+ if sys.version_info[1] < 5:
+ subprocess._cleanup = lambda: None
+ def makebytes(d):
+ return d
+ makestr = makebytes
closefds = os.name == 'posix'
def Popen4(cmd, wd, timeout, env=None):
@@ -764,7 +777,7 @@
fd, name = tempfile.mkstemp(suffix='hg-tst')
try:
for l in script:
- os.write(fd, l)
+ os.write(fd, makebytes(l))
os.close(fd)
cmd = '%s "%s"' % (options.shell, name)
@@ -860,6 +873,7 @@
if abort:
raise KeyboardInterrupt()
+ output = makestr(output)
for s, r in replacements:
output = re.sub(s, r, output)
return ret, output.splitlines(True)
@@ -994,7 +1008,7 @@
# Save errors to a file for diagnosis
f = open(err, "wb")
for line in out:
- f.write(line)
+ f.write(makebytes(line))
f.close()
if skipped: