classification
Title: Nonblocking read sys.stdin raises error
Type: Stage:
Components: Library (Lib), Unicode Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder: subprocess.Popen with universal_newlines and nonblocking streams fails with "can't concat NoneType to bytes"
View: 35762
Assigned To: Nosy List: cykerway, ezio.melotti, martin.panter, terry.reedy, vstinner
Priority: normal Keywords:

Created on 2019-03-14 15:50 by cykerway, last changed 2019-03-15 18:59 by terry.reedy.

Messages (3)
msg337940 - (view) Author: Cyker Way (cykerway) * Date: 2019-03-14 15:50
This piece of code will raise an error:

    import os
    import sys

    os.set_blocking(sys.stdin.fileno(), False)
    sys.stdin.read()

Error:

>   TypeError: can't concat NoneType to bytes

Not sure if this is relevant (for a different version of Python): https://bugs.python.org/issue24560
msg337972 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2019-03-15 08:20
This is the same story as in Issue 35762. Both “sys.stdin” and “subprocess.Popen.stderr” (when universal_newlines=True is enabled) use the TextIOWrapper class, which I don’t think was implemented with non-blocking mode in mind.

Issue 24560 is similar, but is about an older class “codecs.StreamReader”.
msg338015 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-03-15 18:59
Martin, did you mean to close this as a duplicate?
History
Date User Action Args
2019-03-15 18:59:01terry.reedysetnosy: + terry.reedy
messages: + msg338015
2019-03-15 08:20:42martin.pantersetsuperseder: subprocess.Popen with universal_newlines and nonblocking streams fails with "can't concat NoneType to bytes"

messages: + msg337972
nosy: + martin.panter
2019-03-14 15:50:35cykerwaycreate