hook: be prepared for __stdout/err__ not having fileno()
it may have been replaced, see https://bitbucket.org/tortoisehg/thg/issue/937
--- 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'):