classification
Title: TextIOWrapper's write_through option behave differently between C and pure Python implementation.
Type: behavior Stage: resolved
Components: IO Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder: Python version of TextIOWrapper ignores "write_through" arg
View: 15571
Assigned To: Nosy List: benjamin.peterson, methane, serhiy.storchaka, stutzbach
Priority: normal Keywords:

Created on 2017-02-21 09:50 by methane, last changed 2017-05-19 15:08 by serhiy.storchaka. This issue is now closed.

Messages (2)
msg288282 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2017-02-21 09:50
In C implementation, write() calls underlaying flush() method when write_through=True.

https://github.com/python/cpython/blob/3.6/Modules/_io/textio.c

    if (self->write_through)
        text_needflush = 1;
    if (self->line_buffering &&
        (haslf ||
         PyUnicode_FindChar(text, '\r', 0, PyUnicode_GET_LENGTH(text), 1) != -1))
        needflush = 1;


But pure Python implementation doesn't care write_through option at all.

https://github.com/python/cpython/blob/3.6/Lib/_pyio.py

        self.buffer.write(b)
        if self._line_buffering and (haslf or "\r" in s):
            self.flush()

When PyPy 3.5 is released, this difference may affects PyPy users.
(I hadn't checked how PyPy provide io module.)
msg293957 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-19 15:08
This is a duplicate of issue15571.
History
Date User Action Args
2017-05-19 15:08:22serhiy.storchakasetstatus: open -> closed
superseder: Python version of TextIOWrapper ignores "write_through" arg
messages: + msg293957

resolution: not a bug
stage: resolved
2017-02-21 10:34:03serhiy.storchakasetnosy: + benjamin.peterson, stutzbach, serhiy.storchaka
2017-02-21 09:50:54methanecreate