# HG changeset patch # User Idan Kamara # Date 1312058470 -10800 # Node ID e5b2ee5157ae86503901eb7abae42a1ebb002c00 # Parent 188936b334b1f16325da857895982a147b8a7a2c hook: be prepared for __stdout/err__ not having fileno() it may have been replaced, see https://bitbucket.org/tortoisehg/thg/issue/937 diff -r 188936b334b1 -r e5b2ee5157ae mercurial/hook.py --- a/mercurial/hook.py Sat Jul 30 21:04:14 2011 +0300 +++ b/mercurial/hook.py Sat Jul 30 23:41:10 2011 +0300 @@ -134,12 +134,16 @@ oldstdout = -1 if _redirect: - stdoutno = sys.__stdout__.fileno() - stderrno = sys.__stderr__.fileno() - # temporarily redirect stdout to stderr, if possible - if stdoutno >= 0 and stderrno >= 0: - oldstdout = os.dup(stdoutno) - os.dup2(stderrno, stdoutno) + try: + stdoutno = sys.__stdout__.fileno() + stderrno = sys.__stderr__.fileno() + # temporarily redirect stdout to stderr, if possible + if stdoutno >= 0 and stderrno >= 0: + oldstdout = os.dup(stdoutno) + os.dup2(stderrno, stdoutno) + except AttributeError: + # __stdout/err__ doesn't have fileno(), it's not a real file + pass try: for hname, cmd in ui.configitems('hooks'):