Mercurial > hg
changeset 38313:275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
This was breaking in our Python 3 build, but not Python 2. I don't
know how it ever worked in Python 2, but this passes on both.
Differential Revision: https://phab.mercurial-scm.org/D3732
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 14 Jun 2018 11:47:51 -0400 |
parents | 79dd61a4554f |
children | 565074cc9ac6 |
files | mercurial/debugcommands.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Wed Jun 13 22:51:08 2018 +0530 +++ b/mercurial/debugcommands.py Thu Jun 14 11:47:51 2018 -0400 @@ -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)