diff -r 6180dcb29ec5 -r 2c63896783e3 mercurial/hook.py --- 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__'):