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.
--- 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__'):