[issue4263] BufferedWriter non-blocking overage

Sever Băneșiu report at bugs.python.org
Wed Dec 31 13:12:52 CET 2008


Sever Băneșiu <banesiu.sever at gmail.com> added the comment:

Thanks for the new implementation of MockNonBlockWriterIO class. It
makes tests so much easier to read.

There are some minor things in your patch that I would change. For example:

    # 1 byte will be written, the rest will be buffered
    raw.block_on(b"k")
    self.assertEquals(bufio.write(b"jklmn"), 5)
    # ...
    raw.block_on(b"0")

The comment is misleading because in fact no byte is written at raw
level. That's because the data size is smaller than the buffer size and
the buffer is empty (was emptied by the last write call). All this
renders raw.block_on(b"k") call useless. I also think this is the
correct behavior regardless of implementation language of BufferedWriter
class i.e. no write call should write at raw level smaller chunks of
data than buffer's size unless it has to.

Your tests can't cover the pre-flush condition because max_buffer_size
equals buffer_size.

Unless you'll beat me to it or prove me wrong, I'll update your patch
next year.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4263>
_______________________________________


More information about the Python-bugs-list mailing list