classification
Title: `io.BufferedIOBase` returns `None`
Type: Stage: resolved
Components: IO, Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: buffered read() and write() does not raise BlockingIOError
View: 13322
Assigned To: Nosy List: cykerway, martin.panter
Priority: normal Keywords:

Created on 2019-03-14 16:03 by cykerway, last changed 2019-03-15 08:35 by martin.panter. This issue is now closed.

Messages (2)
msg337941 - (view) Author: Cyker Way (cykerway) * Date: 2019-03-14 16:03
Document of [BufferedIOBase](https://docs.python.org/3/library/io.html#io.BufferedIOBase) says:

>   ...unlike their RawIOBase counterparts, they will never return None.

But this example shows the above statement is not true:

    import io
    import os
    import sys

    os.set_blocking(sys.stdin.fileno(), False)
    print(isinstance(sys.stdin.buffer, io.BufferedIOBase))
    print(sys.stdin.buffer.read())

Output:

    True
    None
msg337973 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2019-03-15 08:35
The general problem of non-blocking reads with BufferedIOBase is covered by Issue 13322. The documentation and implementations do not agree. I suggest to not rely on any particular behaviour reading BufferedIOBase objects in non-blocking mode.

The problem of the concrete class BufferedReader (what “stdin.buffer” usually is) was also recently raised in Issue 35869.
History
Date User Action Args
2019-03-15 08:35:11martin.pantersetstatus: open -> closed

superseder: buffered read() and write() does not raise BlockingIOError

nosy: + martin.panter
messages: + msg337973
resolution: duplicate
stage: resolved
2019-03-14 16:03:21cykerwaycreate