Merge lp:~jelmer/brz/fix-stream-buffering into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/fix-stream-buffering
Merge into: lp:brz
Diff against target: 31 lines (+11/-3)
1 file modified
breezy/ui/text.py (+11/-3)
To merge this branch: bzr merge lp:~jelmer/brz/fix-stream-buffering
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+363233@code.launchpad.net

Commit message

Don't buffer more than a line when reading from standard input.

Description of the change

Don't buffer more than a line when reading from standard input.

Without this change, prompts will often hang.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Okay, lets try.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/ui/text.py'
--- breezy/ui/text.py 2018-11-16 12:37:19 +0000
+++ breezy/ui/text.py 2019-02-15 01:29:19 +0000
@@ -19,6 +19,7 @@
19from __future__ import absolute_import19from __future__ import absolute_import
2020
21import codecs21import codecs
22import io
22import os23import os
23import sys24import sys
24import warnings25import warnings
@@ -668,9 +669,16 @@
668def _wrap_in_stream(stream, encoding=None, errors='replace'):669def _wrap_in_stream(stream, encoding=None, errors='replace'):
669 if encoding is None:670 if encoding is None:
670 encoding = _get_stream_encoding(stream)671 encoding = _get_stream_encoding(stream)
671 encoded_stream = codecs.getreader(encoding)(stream, errors=errors)672 # Attempt to wrap using io.open if possible, since that can do
672 encoded_stream.encoding = encoding673 # line-buffering.
673 return encoded_stream674 try:
675 fileno = stream.fileno()
676 except io.UnsupportedOperation:
677 encoded_stream = codecs.getreader(encoding)(stream, errors=errors)
678 encoded_stream.encoding = encoding
679 return encoded_stream
680 else:
681 return io.open(fileno, encoding=encoding, errors=errors, mode='r', buffering=1)
674682
675683
676def _wrap_out_stream(stream, encoding=None, errors='replace'):684def _wrap_out_stream(stream, encoding=None, errors='replace'):

Subscribers

People subscribed via source and target branches