mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Issue #5068: Fixed the tarfile._BZ2Proxy.read() method that would loop
forever on incomplete input. That caused tarfile.open() to hang when used with mode 'r' or 'r:bz2' and a fileobj argument that contained no data or partial bzip2 compressed data.
This commit is contained in:
parent
b364bfe2f4
commit
2020a59563
3 changed files with 34 additions and 5 deletions
|
@ -662,12 +662,11 @@ class _BZ2Proxy(object):
|
|||
b = [self.buf]
|
||||
x = len(self.buf)
|
||||
while x < size:
|
||||
try:
|
||||
raw = self.fileobj.read(self.blocksize)
|
||||
data = self.bz2obj.decompress(raw)
|
||||
b.append(data)
|
||||
except EOFError:
|
||||
raw = self.fileobj.read(self.blocksize)
|
||||
if not raw:
|
||||
break
|
||||
data = self.bz2obj.decompress(raw)
|
||||
b.append(data)
|
||||
x += len(data)
|
||||
self.buf = "".join(b)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue