# HG changeset patch # User Yuya Nishihara # Date 1478612505 -32400 # Node ID 5564fcd031df482d4fe4eb50d959878f55bc960d # Parent ad56204f733ec94e3aceaf0ecd636a05d018a3a3 hook: lower inflated use of sys.__stdout__ and __stderr__ They were introduced at 9f76df0edb7d, where sys.stdout could be replaced by sys.stderr. After that, we've changed the way of stdout redirection by afccc64eea73, so we no longer need to reference the original __stdout__ and __stderr__ objects. Let's move away from using __std*__ objects so we can simply wrap sys.std* objects for Python 3 porting. diff -r ad56204f733e -r 5564fcd031df mercurial/hook.py --- a/mercurial/hook.py Tue Nov 08 22:22:22 2016 +0900 +++ b/mercurial/hook.py Tue Nov 08 22:41:45 2016 +0900 @@ -209,11 +209,11 @@ for hname, cmd in hooks: if oldstdout == -1 and _redirect: try: - stdoutno = sys.__stdout__.fileno() - stderrno = sys.__stderr__.fileno() + stdoutno = sys.stdout.fileno() + stderrno = sys.stderr.fileno() # temporarily redirect stdout to stderr, if possible if stdoutno >= 0 and stderrno >= 0: - sys.__stdout__.flush() + sys.stdout.flush() oldstdout = os.dup(stdoutno) os.dup2(stderrno, stdoutno) except (OSError, AttributeError): @@ -258,7 +258,7 @@ sys.stderr.flush() finally: if _redirect and oldstdout >= 0: - sys.__stdout__.flush() # write hook output to stderr fd + sys.stdout.flush() # write hook output to stderr fd os.dup2(oldstdout, stdoutno) os.close(oldstdout)