diff mercurial/patch.py @ 30924:48dea083f66d

py3: convert the mode argument of os.fdopen to unicodes (1 of 2) os.fdopen() does not accepts bytes as its second argument which represent the mode in which the file is to be opened. This patch makes sure unicodes are passed in py3 by using pycompat.sysstr().
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 13 Feb 2017 20:06:38 +0530
parents 897726622877
children 71a6723c0029
line wrap: on
line diff
--- a/mercurial/patch.py	Thu Feb 09 15:20:41 2017 -0500
+++ b/mercurial/patch.py	Mon Feb 13 20:06:38 2017 +0530
@@ -34,6 +34,7 @@
     mail,
     mdiff,
     pathutil,
+    pycompat,
     scmutil,
     similar,
     util,
@@ -209,7 +210,7 @@
 
     data = {}
     fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
-    tmpfp = os.fdopen(fd, 'w')
+    tmpfp = os.fdopen(fd, pycompat.sysstr('w'))
     try:
         msg = email.Parser.Parser().parse(fileobj)
 
@@ -1055,7 +1056,7 @@
                 ncpatchfp = None
                 try:
                     # Write the initial patch
-                    f = os.fdopen(patchfd, "w")
+                    f = os.fdopen(patchfd, pycompat.sysstr("w"))
                     chunk.header.write(f)
                     chunk.write(f)
                     f.write('\n'.join(['# ' + i for i in phelp.splitlines()]))