Message96537
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. |
|
Date |
User |
Action |
Args |
2009-12-17 22:07:15 | pitrou | set | recipients:
+ pitrou, jackdied, nirai, brian.curtin, asnakelover |
2009-12-17 22:07:15 | pitrou | set | messageid: <1261087635.24.0.417328515487.issue7471@psf.upfronthosting.co.za> |
2009-12-17 22:07:13 | pitrou | link | issue7471 messages |
2009-12-17 22:07:13 | pitrou | create | |
|