This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients asnakelover, brian.curtin, jackdied, nirai, pitrou
Date 2009-12-17.22:07:13
SpamBayes Score 4.55995e-11
Marked as misclassified No
Message-id <>
Thanks for the new patch. The problem with inheriting from
BufferedRandom, though, is that if you call e.g. write() on a read-only
gzipfile, it will appear to succeed because the bytes are buffered

I think the solution would be to use delegation rather than inheritance.
Something like:

    def __init__(self, ...)
        if 'w' in mode:
           self.buf = BufferedWriter(...)
        for meth in ('read', 'write', etc.):
            setattr(self, meth, getattr(self.buf, meth))

It would also be nice to add some tests for the issues I mentioned
earlier (check that IOError is raised when reading a write-only file,
and vice-versa).

By the way, we can't apply this approach to 2.x since
BufferedWriter/BufferedRandom won't accept unicode arguments for write()
and friends, and that would break compatibility. For 3.x it is fine though.
Date User Action Args
2009-12-17 22:07:15pitrousetrecipients: + pitrou, jackdied, nirai, brian.curtin, asnakelover
2009-12-17 22:07:15pitrousetmessageid: <>
2009-12-17 22:07:13pitroulinkissue7471 messages
2009-12-17 22:07:13pitroucreate