Mercurial > public > mercurial-scm > hg
diff mercurial/dispatch.py @ 34533:163fa0aea71e
dispatch: move initialization of sys.std* files
I'll add another Python 3 hack.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 02 Oct 2017 07:18:24 +0100 |
parents | b09b3eaf9c96 |
children | 021607b4ef49 |
line wrap: on
line diff
--- a/mercurial/dispatch.py Mon Oct 02 06:52:10 2017 +0100 +++ b/mercurial/dispatch.py Mon Oct 02 07:18:24 2017 +0100 @@ -75,6 +75,7 @@ def run(): "run the command in sys.argv" + _initstdio() req = request(pycompat.sysargv[1:]) err = None try: @@ -95,6 +96,10 @@ req.ui.ferr.flush() sys.exit(status & 255) +def _initstdio(): + for fp in (sys.stdin, sys.stdout, sys.stderr): + util.setbinary(fp) + def _getsimilar(symbols, value): sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio() # The cutoff for similarity here is pretty arbitrary. It should