Submitter | Yuya Nishihara |
---|---|
Date | Oct. 4, 2017, 2:53 p.m. |
Message ID | <fecbf1e8aa17474f448e.1507128836@mimosa> |
Download | mbox | patch |
Permalink | /patch/24493/ |
State | Accepted |
Headers | show |
Comments
On Wed, 04 Oct 2017 23:53:56 +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1506923984 -3600 > # Mon Oct 02 06:59:44 2017 +0100 > # Node ID fecbf1e8aa17474f448e126697fe287e44c92664 > # Parent 2b071e9303f748de41c02efdea158883d336224a > py3: fully detach TextIOWrapper Unfortunately, this broke test-py3-commands.t and it seems the Python interpreter really hates detaching TextIOWrapper from stdio. So I'm going to drop this and the next patch.
> On Oct 10, 2017, at 10:20, Yuya Nishihara <yuya@tcha.org> wrote: > > On Wed, 04 Oct 2017 23:53:56 +0900, Yuya Nishihara wrote: >> # HG changeset patch >> # User Yuya Nishihara <yuya@tcha.org> >> # Date 1506923984 -3600 >> # Mon Oct 02 06:59:44 2017 +0100 >> # Node ID fecbf1e8aa17474f448e126697fe287e44c92664 >> # Parent 2b071e9303f748de41c02efdea158883d336224a >> py3: fully detach TextIOWrapper > > Unfortunately, this broke test-py3-commands.t and it seems the Python > interpreter really hates detaching TextIOWrapper from stdio. So I'm going > to drop this and the next patch. Ugh, python3. Thanks.
Patch
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -96,9 +96,15 @@ def run(): req.ui.ferr.flush() sys.exit(status & 255) -def _initstdio(): - for fp in (sys.stdin, sys.stdout, sys.stderr): - util.setbinary(fp) +if pycompat.ispy3: + def _initstdio(): + # detach wrapper so it will never flush() underlying IO implicitly + for fp in (sys.stdin, sys.stdout, sys.stderr): + fp.detach() +else: + 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()