diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -215,7 +215,7 @@ data = {} fd, tmpname = tempfile.mkstemp(prefix='hg-patch-') - tmpfp = os.fdopen(fd, pycompat.sysstr('w')) + tmpfp = os.fdopen(fd, pycompat.sysstr('wb')) try: msg = pycompat.emailparser().parse(fileobj)