Skip to content

Binary over sys.stdin question, sys.stdin is type TextIOWrapper, not FileIO? #12070

Closed Answered by jimmo
stephanelsmith asked this question in Unix & Windows
Discussion options

You must be logged in to vote

@stephanelsmith

On unix port, I'type of sys.stdin is a TextIOWrapper.

This is the correct behavior. However what's missing is that it should have a .buffer attribute to access the underlying binary stream -- this is the CPython-compatible way to do this (see the note at the end of the sys.stdin docs -- https://docs.python.org/3/library/sys.html#sys.stderr ).

Conversely, on ESP32, sys.stdin is a FileIO with sys.stdin.buffer available for use.

Confusingly, despite being named FileIO, this object (on all the embedded ports) is actually a TextIOWrapper-like implementation. It is a text stream, and supports the .buffer attribute to get the underlying binary stream.

I don't know the history…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@stephanelsmith
Comment options

@jimmo
Comment options

@stephanelsmith
Comment options

@jimmo
Comment options

Comment options

You must be logged in to vote
1 reply
@stephanelsmith
Comment options

Answer selected by stephanelsmith
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy