# HG changeset patch # Parent ca54c27a9045c655ef1ad9ce248f02eb00137476 diff -r ca54c27a9045 -r 1776829d890f Lib/subprocess.py --- a/Lib/subprocess.py Tue Aug 21 14:54:22 2012 +0100 +++ b/Lib/subprocess.py Tue Aug 21 22:47:06 2012 +0100 @@ -1152,8 +1152,18 @@ def _readerthread(self, fh, buffer): - buffer.append(fh.read()) - fh.close() + try: + L = [] + while True: + chunk = fh.read(4096) + if not chunk: + break + L.append(chunk) + finally: + fh.close() + empty_string = type(chunk)() # either '' or b'' + result = empty_string.join(L) + buffer.append(result) def _communicate(self, input, endtime, orig_timeout):