Merged revisions 70523 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70523 | lars.gustaebel | 2009-03-22 21:09:33 +0100 (Sun, 22 Mar 2009) | 5 lines
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.
........
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index b678185..8e98dfa 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -662,12 +662,11 @@
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)