Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell()

work correctly together with readline().

(backport from rev. 53153)
This commit is contained in:
Lars Gustäbel 2006-12-23 16:51:47 +00:00
parent 60775f29de
commit aedb92e59c
3 changed files with 180 additions and 120 deletions

View file

@ -110,7 +110,7 @@ class ReadTest(BaseTest):
"""Test seek() method of _FileObject, incl. random reading.
"""
if self.sep != "|":
filename = "0-REGTYPE"
filename = "0-REGTYPE-TEXT"
self.tar.extract(filename, dirname())
f = open(os.path.join(dirname(), filename), "rb")
data = f.read()
@ -149,6 +149,16 @@ class ReadTest(BaseTest):
s2 = fobj.readlines()
self.assert_(s1 == s2,
"readlines() after seek failed")
fobj.seek(0)
self.assert_(len(fobj.readline()) == fobj.tell(),
"tell() after readline() failed")
fobj.seek(512)
self.assert_(len(fobj.readline()) + 512 == fobj.tell(),
"tell() after seek() and readline() failed")
fobj.seek(0)
line = fobj.readline()
self.assert_(fobj.read() == data[len(line):],
"read() after readline() failed")
fobj.close()
def test_old_dirtype(self):