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

login
register
mail settings
Submitter phabricator
Date Feb. 18, 2018, 1:31 p.m.
Message ID <differential-rev-PHID-DREV-ryq6nje6lidbyw4zmbuq-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28086/
State Superseded
Headers show

Comments

phabricator - Feb. 18, 2018, 1:31 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/posix.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 18, 2018, 2:12 p.m.
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> posix.py:116
>              # switch file to link
>              fp = open(f)
>              data = fp.read()

Two more missing 'b's, here

> posix.py:124
>                  # failed to make a link, rewrite file
>                  fp = open(f, "w")
>                  fp.write(data)

and here.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
phabricator - Feb. 19, 2018, noon
yuja added inline comments.

INLINE COMMENTS

> posix.py:116
>              # switch file to link
> -            fp = open(f)
> +            fp = open(f, 'wb')
>              data = fp.read()

should be 'rb'

Fixed in flight.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -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