Author nadeem.vawda
Recipients MizardX, eric.araujo, nadeem.vawda, niemeyer, pitrou, rhettinger, wrobell, xuanji
Date 2011-01-25.03:15:38
SpamBayes Score 1.69685e-09
Marked as misclassified No
Message-id <1295925346.87.0.46855002786.issue5863@psf.upfronthosting.co.za>
In-reply-to
Content
Here is a patch that rewrites BZ2File to implement the requested feature, and adds some tests using BytesIO objects.

Some notes:
* iteration and the read*() method now use the same buffering machinery, so they can be mixed freely. The test for issue8397 has been updated accordingly.
* readlines() now respects its size argument. The existing implementation appears to effectively ignore it.
* writelines() no longer uses the (deprecated) old buffer protocol, and is now much simpler.
* Currently, calling next() on a writable BZ2File results in a rather unhelpful error message; the patched version checks that the file is readable before trying to actually read.
* The docstrings have been rewritten to clarify that all of the methods deal with bytes and not text strings.

One thing I was unsure of is how to handle exceptions that occur in BZ2File_dealloc(). Does the error status need to be cleared before it returns?

The documentation for the bz2 module appears to be quite out of date; I will upload a patch in the next day or so.

On a related note, the 'buffering' argument to __init__() is ignored, and I was wondering whether this should be documented explicitly? The current documentation claims that it allows the caller to specify a buffer size, or request unbuffered I/O.
History
Date User Action Args
2011-01-25 03:15:46nadeem.vawdasetrecipients: + nadeem.vawda, rhettinger, niemeyer, pitrou, wrobell, eric.araujo, MizardX, xuanji
2011-01-25 03:15:46nadeem.vawdasetmessageid: <1295925346.87.0.46855002786.issue5863@psf.upfronthosting.co.za>
2011-01-25 03:15:40nadeem.vawdalinkissue5863 messages
2011-01-25 03:15:40nadeem.vawdacreate