Patchwork [2,of,2] sshpeer: check pipe validity before forwarding output from it

login
register
mail settings
Submitter Matt Harbison
Date March 10, 2018, 6:05 p.m.
Message ID <0e076d66888bff8e3eac.1520705127@Envy>
Download mbox | patch
Permalink /patch/29253/
State Accepted
Headers show

Comments

Matt Harbison - March 10, 2018, 6:05 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1520703910 18000
#      Sat Mar 10 12:45:10 2018 -0500
# Node ID 0e076d66888bff8e3eac166454bb3214c48ff8be
# Parent  e21d0c21f81315d012c4806359bc76aa40c89ad6
sshpeer: check pipe validity before forwarding output from it

After the previous fix, fileobjectproxy._observedcall() (called when
win32.peekpipe() accesses .fileno) started exploding.  With this fix, similar
checks are needed inside debugwireproto().  Since that is hardcoded to not use
os.devnull, IDK if those are worth fixing.

Patch

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -32,10 +32,11 @@  def _forwardoutput(ui, pipe):
     """display all data currently available on pipe as remote output.
 
     This is non blocking."""
-    s = util.readpipe(pipe)
-    if s:
-        for l in s.splitlines():
-            ui.status(_("remote: "), l, '\n')
+    if pipe:
+        s = util.readpipe(pipe)
+        if s:
+            for l in s.splitlines():
+                ui.status(_("remote: "), l, '\n')
 
 class doublepipe(object):
     """Operate a side-channel pipe in addition of a main one