Miscellaneous cleanups to bz2 and test_bz2 following issue #1625.
* In bz2.decompress(), concatenate partial results in a way that should
be more friendly to other Python implementations
* Remove redundant comments in test_bz2
* Use 'while True:' instead of 'while 1:'
diff --git a/Lib/bz2.py b/Lib/bz2.py
index 4b25f5d..cc71ae0 100644
--- a/Lib/bz2.py
+++ b/Lib/bz2.py
@@ -400,14 +400,14 @@
if len(data) == 0:
return b""
- result = b""
+ results = []
while True:
decomp = BZ2Decompressor()
- result += decomp.decompress(data)
+ results.append(decomp.decompress(data))
if not decomp.eof:
raise ValueError("Compressed data ended before the "
"end-of-stream marker was reached")
if not decomp.unused_data:
- return result
+ return b"".join(results)
# There is unused data left over. Proceed to next stream.
data = decomp.unused_data