Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uio.TextIOWrapper() behavior #11

Closed
pfalcon opened this issue Jul 31, 2018 · 1 comment
Closed

Fix uio.TextIOWrapper() behavior #11

pfalcon opened this issue Jul 31, 2018 · 1 comment

Comments

@pfalcon
Copy link
Owner

pfalcon commented Jul 31, 2018

Currently, it has constructor uio.TextIOWrapper(filename). Instead, it should be uio.TextIOWrapper(stream): https://docs.python.org/3/library/io.html#io.TextIOWrapper

Current situation effectively means that there's no way to convert a binary stream to text stream (socket has a workaround using .makefile() method).

@pfalcon pfalcon mentioned this issue Sep 3, 2018
15 tasks
@pfalcon
Copy link
Owner Author

pfalcon commented Aug 6, 2020

io.TextIOWrapper is explicitly documented as buffered stream in CPython docs. As supporting buffered text streams is a separate issue, it was decided to implement needed functionality on the level of uio.TextIOBase. In CPython, it's an abstract base class, but we recast it as a generic, unbuffered adapter from binary to text streams.

So, now it's possible to do uio.TextIOBase(uio.BytesIO(b"1234")).

This change is made so far to the unix port, other ports need to catch up with it later. (For now, they keep using old uio.TextIOWrapper, so it's left in the codebase.)

@pfalcon pfalcon closed this as completed Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant