Patchwork D3732: debugcommands: work around logiofd being a pipe and unseekable

login
register
mail settings
Submitter phabricator
Date June 14, 2018, 4:11 p.m.
Message ID <differential-rev-PHID-DREV-vlsztownovbemie7pop5-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32139/
State Superseded
Headers show

Comments

phabricator - June 14, 2018, 4:11 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS




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

Patch

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)