mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Patch #448474: Add support for tell() and seek() to gzip.GzipFile.
This commit is contained in:
parent
f30f1fc900
commit
8cc965c1fb
3 changed files with 60 additions and 4 deletions
|
@ -50,5 +50,29 @@ while 1:
|
|||
if L == []: break
|
||||
f.close()
|
||||
|
||||
# Try seek, read test
|
||||
|
||||
f = gzip.GzipFile(filename)
|
||||
while 1:
|
||||
oldpos = f.tell()
|
||||
line1 = f.readline()
|
||||
if not line1: break
|
||||
newpos = f.tell()
|
||||
f.seek(oldpos) # negative seek
|
||||
if len(line1)>10:
|
||||
amount = 10
|
||||
else:
|
||||
amount = len(line1)
|
||||
line2 = f.read(amount)
|
||||
verify(line1[:amount] == line2)
|
||||
f.seek(newpos) # positive seek
|
||||
f.close()
|
||||
|
||||
# Try seek, write test
|
||||
f = gzip.GzipFile(filename, 'w')
|
||||
for pos in range(0, 256, 16):
|
||||
f.seek(pos)
|
||||
f.write('GZ\n')
|
||||
f.close()
|
||||
|
||||
os.unlink(filename)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue