changeset 17964:2c63896783e3 stable

hooks: be even more forgiven of non-fd descriptors (issue3711) Looks like there are instances where sys.stdout/stderr contain file handles that are invalid. We should be tolerant of this for hook I/O redirection, as our primary concern is not garbling our own output stream.
author Matt Mackall <mpm@selenic.com>
date Mon, 26 Nov 2012 17:48:39 -0600
parents 6180dcb29ec5
children b3ec0b5fd777
files mercurial/hook.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hook.py	Mon Nov 26 16:14:22 2012 -0600
+++ b/mercurial/hook.py	Mon Nov 26 17:48:39 2012 -0600
@@ -158,8 +158,8 @@
                         sys.__stdout__.flush()
                         oldstdout = os.dup(stdoutno)
                         os.dup2(stderrno, stdoutno)
-                except AttributeError:
-                    # __stdout__/__stderr__ has no fileno(), not a real file
+                except (OSError, AttributeError):
+                    # files seem to be bogus, give up on redirecting (WSGI, etc)
                     pass
 
             if util.safehasattr(cmd, '__call__'):