diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e7fd47f..4410053a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Added thread to automatically call update() in progress.track(). Replacing previous adaptive algorithm. +- Second attempt at working around https://bugs.python.org/issue37871 ## [4.2.1] - 2020-07-29 diff --git a/rich/__main__.py b/rich/__main__.py index e5db07f7..da57fe57 100644 --- a/rich/__main__.py +++ b/rich/__main__.py @@ -180,7 +180,7 @@ if __name__ == "__main__": # pragma: no cover text = console.file.getvalue() # https://bugs.python.org/issue37871 - for offset in range(0, len(text), 8192): - print(text[offset : offset + 8192], end="") + for line in text.splitlines(): + print(line) print(f"rendered in {taken}ms") diff --git a/rich/console.py b/rich/console.py index d8b517f3..de5c2ab8 100644 --- a/rich/console.py +++ b/rich/console.py @@ -986,10 +986,9 @@ class Console: if text: if WINDOWS: # pragma: no cover # https://bugs.python.org/issue37871 - CHUNK_SIZE = 8192 write = self.file.write - for offset in range(0, len(text), CHUNK_SIZE): - write(text[offset : offset + CHUNK_SIZE]) + for line in text.splitlines(True): + write(line) else: self.file.write(text) self.file.flush()