mirror of
https://git.code.sf.net/p/archivemail/code
synced 2024-12-22 07:42:55 +00:00
test suite: let FixedGzipFile.seek() pass on what gzip.GzipFile.seek() returned
This fixes test suite failures with Python 2.7. Starting with Python 2.7, gzip.GzipFile is subclassing io.IOBase. The seek() method of io.IOBase differs from file.seek() and the old gzip.GzipFile.seek() in that it returns the new file position, not None. And in Python 2.7, gzip.GzipFile.tell() is inherited from io.IOBase.tell(), which is implemented using its seek() method. FixedGzipFile subclasses gzip.GzipFile and overrides seek(); therefore, this method need be adapted for this change in the interface. Closes: #3314293.
This commit is contained in:
parent
39e6a532d0
commit
f6046b9d69
2 changed files with 7 additions and 2 deletions
|
@ -3,6 +3,9 @@ version 0.?.? - UNRELEASED
|
|||
* Fixed manpage installation path to be FHS compliant
|
||||
* Speed up IMAP archiving with the --quiet option
|
||||
* Ported the manpage from SGML to XML
|
||||
* Fix test suite failures with Python 2.7 by letting the test suite method
|
||||
FixedGzipFile.seek() return the new absolute file position.
|
||||
Closes: #3314293.
|
||||
|
||||
version 0.8.2 - 16 October 2010
|
||||
|
||||
|
|
|
@ -85,14 +85,16 @@ class FixedGzipFile(gzip.GzipFile):
|
|||
"""GzipFile with seek method accepting whence parameter."""
|
||||
def seek(self, offset, whence=0):
|
||||
try:
|
||||
gzip.GzipFile.seek(self, offset, whence)
|
||||
# Try calling gzip.GzipFile.seek with the whence parameter.
|
||||
# For Python >= 2.7, it returns the new offset; pass that on.
|
||||
return gzip.GzipFile.seek(self, offset, whence)
|
||||
except TypeError:
|
||||
if whence:
|
||||
if whence == 1:
|
||||
offset = self.offset + offset
|
||||
else:
|
||||
raise ValueError('Seek from end not supported')
|
||||
gzip.GzipFile.seek(self, offset)
|
||||
return gzip.GzipFile.seek(self, offset)
|
||||
|
||||
# precision of os.utime() when restoring mbox timestamps
|
||||
utimes_precision = 5
|
||||
|
|
Loading…
Reference in a new issue