changeset 36303:ed95758addf3

py3: make sure we open the files in bytes mode Differential Revision: https://phab.mercurial-scm.org/D2333
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 18 Feb 2018 18:22:40 +0530
parents ba1807d9a846
children 6d6bc544467a
files mercurial/posix.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/posix.py	Sun Feb 18 00:59:03 2018 -0500
+++ b/mercurial/posix.py	Sun Feb 18 18:22:40 2018 +0530
@@ -113,7 +113,7 @@
     if l:
         if not stat.S_ISLNK(s):
             # switch file to link
-            fp = open(f)
+            fp = open(f, 'rb')
             data = fp.read()
             fp.close()
             unlink(f)
@@ -121,7 +121,7 @@
                 os.symlink(data, f)
             except OSError:
                 # failed to make a link, rewrite file
-                fp = open(f, "w")
+                fp = open(f, "wb")
                 fp.write(data)
                 fp.close()
         # no chmod needed at this point
@@ -130,7 +130,7 @@
         # switch link to file
         data = os.readlink(f)
         unlink(f)
-        fp = open(f, "w")
+        fp = open(f, "wb")
         fp.write(data)
         fp.close()
         s = 0o666 & ~umask # avoid restatting for chmod