# HG changeset patch # User Gregory Szorc # Date 2018-02-11 23:58:31 # Node ID bff95b002e33652a3b69f3fb7319ce7df5d75b30 # Parent c33a99506e13fb5278f040d5ce56cdc09c8fa5b6 py3: open patches.queue in binary mode And switch to using the context manager form of open() while we're here. Differential Revision: https://phab.mercurial-scm.org/D2153 diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -445,9 +445,9 @@ class queue(object): 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: