diff options
author | Lars Gustäbel <lars@gustaebel.de> | 2009-03-22 20:48:03 +0000 |
---|---|---|
committer | Lars Gustäbel <lars@gustaebel.de> | 2009-03-22 20:48:03 +0000 |
commit | 7623294cb76b23d63df2858df71072721bf409cc (patch) | |
tree | 1795e28745da5abb35df75897f63894bbe325f99 /Lib/tarfile.py | |
parent | f73bf859425040d2d27499ae89bc229fb5496b00 (diff) | |
download | cpython-git-7623294cb76b23d63df2858df71072721bf409cc.tar.gz |
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.
(backported from r70523)
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 5ad096dbf3..8b477fe76e 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -594,12 +594,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) |