Antoine Pitrou <pit...@free.fr> added the comment: 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 internally.
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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7471> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com