This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Nonblocking read sys.stdin raises error
Type: Stage: resolved
Components: Library (Lib), Unicode Versions: Python 3.7
process
Status: closed Resolution: duplicate
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 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
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?
msg339236 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2019-03-31 01:12
I wasn’t sure about closing it, in case Cyker came back with more details. E.g. what was the use case? Were they mislead by the documentation? Do they just think the error should be different, or do they think there should be no error in this case?

But I suppose we can close this and keep discussion about non-blocking text input together in the existing reports.
History
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80474
2019-03-31 01:13:11martin.pantersetresolution: duplicate
2019-03-31 01:12:56martin.pantersetstatus: open -> closed

messages: + msg339236
stage: resolved
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