Skip to content
Snippets Groups Projects
Commit e5b2ee51 authored by Idan Kamara's avatar Idan Kamara
Browse files

hook: be prepared for __stdout/err__ not having fileno()

it may have been replaced, see https://bitbucket.org/tortoisehg/thg/issue/937
parent 188936b3
No related merge requests found
......@@ -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'):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment