Message6757

Author r_walter
Recipients ArneBab, cowwoc, crankycoder, ita, pjdm, pjenvey, r_walter, spiritmech
Date 2012-01-12.21:58:23
SpamBayes Score 3.3916209e-07
Marked as misclassified No
Message-id <1326405504.25.0.274794957769.issue1445@psf.upfronthosting.co.za>
In-reply-to
Content
What in bz2_v2 in the class BZ2File is missing, is the seek method. This is essential for the support of the tarfile module. My simple implementation idea is, for reading mode and the whence SEEK_SET: Do nothing when position given is the actual, when argument is greater than actual position do so many dummy reads as the difference, when the argument is smaller, reopen the underlying java stream and do dummy reads as often as the argument says.

This is similar for SEEK_CUR.

SEEK_END is in my opinion not supportable.

Another essential point for the tarfile support is, do not throw exceptions in the constructor, when the arguments are correct. You must defer that to the I/O operations like read() and seek(). When they are called raise an IOError("invalid data stream"). This is needed for the auto detection of the used compression algorithm when you give only "r" as mode to the tarfile.open().
History
Date User Action Args
2012-01-12 21:58:24r_waltersetmessageid: <1326405504.25.0.274794957769.issue1445@psf.upfronthosting.co.za>
2012-01-12 21:58:24r_waltersetrecipients: + r_walter, pjenvey, crankycoder, ita, pjdm, spiritmech, cowwoc, ArneBab
2012-01-12 21:58:24r_walterlinkissue1445 messages
2012-01-12 21:58:23r_waltercreate