Patchwork D1797: py3: make sure we open the file to write in bytes mode

login
register
mail settings
Submitter phabricator
Date Dec. 29, 2017, 12:50 a.m.
Message ID <differential-rev-PHID-DREV-rnq7xuujgdk2dcy3o4om-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26494/
State Superseded
Headers show

Comments

phabricator - Dec. 29, 2017, 12:50 a.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/D1797

AFFECTED FILES
  mercurial/subrepo.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 11, 2018, 2:40 p.m.
yuja added inline comments.

INLINE COMMENTS

> subrepo.py:844
>  
> -            fp = self._repo.vfs("hgrc", "w", text=True)
> +            fp = self._repo.vfs("hgrc", "wb", text=True)
>              try:

No. Here we explicitly states that we want to open a file in "text" mode.

Needs something like https://phab.mercurial-scm.org/rHGac69675fff1caacf143ab7f0bda668e6e325670a.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -811,7 +811,7 @@ 
         with self._repo.lock():
             storehash = list(self._calcstorehash(remotepath))
             vfs = self._cachestorehashvfs
-            vfs.writelines(cachefile, storehash, mode='w', notindexed=True)
+            vfs.writelines(cachefile, storehash, mode='wb', notindexed=True)
 
     def _getctx(self):
         '''fetch the context for this subrepo revision, possibly a workingctx
@@ -841,7 +841,7 @@ 
             if defpath != defpushpath:
                 addpathconfig('default-push', defpushpath)
 
-            fp = self._repo.vfs("hgrc", "w", text=True)
+            fp = self._repo.vfs("hgrc", "wb", text=True)
             try:
                 fp.write(''.join(lines))
             finally: