Patchwork D2153: py3: open patches.queue in binary mode

login
register
mail settings
Submitter phabricator
Date Feb. 12, 2018, 2:36 a.m.
Message ID <differential-rev-PHID-DREV-luyk7wf44m2ckz3gqpn6-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27628/
State Superseded
Headers show

Comments

phabricator - Feb. 12, 2018, 2:36 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  And switch to using the context manager form of open() while we're
  here.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/mq.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -445,9 +445,9 @@ 
     def __init__(self, ui, baseui, path, patchdir=None):
         self.basepath = path
         try:
-            fh = open(os.path.join(path, 'patches.queue'))
-            cur = fh.read().rstrip()
-            fh.close()
+            with open(os.path.join(path, 'patches.queue'), r'rb') as fh:
+                cur = fh.read().rstrip()
+
             if not cur:
                 curpath = os.path.join(path, 'patches')
             else: