Author vstinner
Recipients vstinner
Date 2019-06-11.00:18:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560212298.77.0.66592947887.issue37223@roundup.psfhosted.org>
In-reply-to
Content
PR 13952 fix many errors, but not of all them.

test_io.PyBufferedWriterTest.test_misbehaved_io() logs a warning, whereas test_io.CBufferedWriterTest.test_misbehaved_io() doesn't. It seems like _pyio.BufferedWriter lacks bpo-32228 fix.

Extract of the C implementation:

static PyObject *
_bufferedwriter_flush_unlocked(buffered *self)
{
    ...

    if (!VALID_WRITE_BUFFER(self) || self->write_pos == self->write_end)
        goto end;

    /* First, rewind */
    rewind = RAW_OFFSET(self) + (self->pos - self->write_pos);
    if (rewind != 0) {
        n = _buffered_raw_seek(self, -rewind, 1);
        if (n < 0) {
            goto error;
        }
        self->raw_pos -= rewind;
    }
    ...


end:
    /* This ensures that after return from this function,
       VALID_WRITE_BUFFER(self) returns false.

       This is a required condition because when a tell() is called
       after flushing and if VALID_READ_BUFFER(self) is false, we need
       VALID_WRITE_BUFFER(self) to be false to have
       RAW_OFFSET(self) == 0.

       Issue: https://bugs.python.org/issue32228 */
    _bufferedwriter_reset_buf(self);
    Py_RETURN_NONE;

error:
    return NULL;
}
History
Date User Action Args
2019-06-11 00:18:18vstinnersetrecipients: + vstinner
2019-06-11 00:18:18vstinnersetmessageid: <1560212298.77.0.66592947887.issue37223@roundup.psfhosted.org>
2019-06-11 00:18:18vstinnerlinkissue37223 messages
2019-06-11 00:18:18vstinnercreate