From patchwork Fri Jun 15 12:48:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D3732: debugcommands: work around logiofd being a pipe and unseekable From: phabricator X-Patchwork-Id: 32164 Message-Id: <0037ca3d3b8806ab9844efba20c68e5f@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Date: Fri, 15 Jun 2018 12:48:32 +0000 This revision was automatically updated to reflect the committed changes. Closed by commit rHG275cc461b854: debugcommands: work around logiofd being a pipe and unseekable (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3732?vs=9057&id=9080 REVISION DETAIL https://phab.mercurial-scm.org/D3732 AFFECTED FILES mercurial/debugcommands.py CHANGE DETAILS To: durin42, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -2289,7 +2289,13 @@ if opts['logiofd']: # Line buffered because output is line based. - logfh = os.fdopen(int(opts['logiofd']), r'ab', 1) + try: + logfh = os.fdopen(int(opts['logiofd']), r'ab', 1) + except OSError as e: + if e.errno != errno.ESPIPE: + raise + # can't seek a pipe, so `ab` mode fails on py3 + logfh = os.fdopen(int(opts['logiofd']), r'wb', 1) elif opts['logiofile']: logfh = open(opts['logiofile'], 'ab', 1)