[Python-checkins] r52737 - in python/trunk: Lib/gzip.py Lib/test/test_gzip.py Misc/NEWS
martin.v.loewis
python-checkins at python.org
Sun Nov 12 11:41:40 CET 2006
Author: martin.v.loewis
Date: Sun Nov 12 11:41:39 2006
New Revision: 52737
Modified:
python/trunk/Lib/gzip.py
python/trunk/Lib/test/test_gzip.py
python/trunk/Misc/NEWS
Log:
Patch #1355023: support whence argument for GzipFile.seek.
Modified: python/trunk/Lib/gzip.py
==============================================================================
--- python/trunk/Lib/gzip.py (original)
+++ python/trunk/Lib/gzip.py Sun Nov 12 11:41:39 2006
@@ -371,7 +371,12 @@
self.extrasize = 0
self.offset = 0
- def seek(self, offset):
+ def seek(self, offset, whence=0):
+ if whence:
+ if whence == 1:
+ offset = self.offset + offset
+ else:
+ raise ValueError('Seek from end not supported')
if self.mode == WRITE:
if offset < self.offset:
raise IOError('Negative seek in write mode')
Modified: python/trunk/Lib/test/test_gzip.py
==============================================================================
--- python/trunk/Lib/test/test_gzip.py (original)
+++ python/trunk/Lib/test/test_gzip.py Sun Nov 12 11:41:39 2006
@@ -128,6 +128,17 @@
f.seek(newpos) # positive seek
f.close()
+ def test_seek_whence(self):
+ self.test_write()
+ # Try seek(whence=1), read test
+
+ f = gzip.GzipFile(self.filename)
+ f.read(10)
+ f.seek(10, whence=1)
+ y = f.read(10)
+ f.close()
+ self.assertEquals(y, data1[20:30])
+
def test_seek_write(self):
# Try seek, write test
f = gzip.GzipFile(self.filename, 'w')
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sun Nov 12 11:41:39 2006
@@ -96,6 +96,8 @@
Library
-------
+- Patch #1355023: support whence argument for GzipFile.seek.
+
- Patch #1065257: Support passing open files as body in
HTTPConnection.request().
More information about the Python-checkins
mailing list