Patchwork D2333: py3: make sure we open the files in bytes mode

login
register
mail settings
Submitter phabricator
Date Feb. 18, 2018, 2:41 p.m.
Message ID <3fce8125b6ae6ef029fdad91a1f7ccee@localhost.localdomain>
Download mbox | patch
Permalink /patch/28105/
State Not Applicable
Headers show

Comments

phabricator - Feb. 18, 2018, 2:41 p.m.
pulkit updated this revision to Diff 5879.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2333?vs=5862&id=5879

REVISION DETAIL
  https://phab.mercurial-scm.org/D2333

AFFECTED FILES
  mercurial/posix.py

CHANGE DETAILS




To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -113,24 +113,24 @@ 
     if l:
         if not stat.S_ISLNK(s):
             # switch file to link
-            fp = open(f)
+            fp = open(f, 'wb')
             data = fp.read()
             fp.close()
             unlink(f)
             try:
                 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
         return
     if stat.S_ISLNK(s):
         # 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