diff -r d83191e9749b -r 00e4bd97b095 mercurial/patch.py --- a/mercurial/patch.py Sat Apr 07 13:46:32 2018 +0900 +++ b/mercurial/patch.py Sat Apr 07 20:50:38 2018 +0900 @@ -2103,8 +2103,9 @@ cwd = repo.root if cwd: args.append('-d %s' % procutil.shellquote(cwd)) - fp = procutil.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip, - procutil.shellquote(patchname))) + cmd = ('%s %s -p%d < %s' + % (patcher, ' '.join(args), strip, procutil.shellquote(patchname))) + fp = procutil.popen(cmd, 'rb') try: for line in util.iterfile(fp): line = line.rstrip()