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

Add an input method to Console #11398

Closed
stuhood opened this issue Dec 30, 2020 · 4 comments · Fixed by #11703
Closed

Add an input method to Console #11398

stuhood opened this issue Dec 30, 2020 · 4 comments · Fixed by #11703
Assignees

Comments

@stuhood
Copy link
Member

stuhood commented Dec 30, 2020

To support usecases that consume user input, we should add the equivalent of input to Console.

@stuhood
Copy link
Member Author

stuhood commented Mar 2, 2021

#11536 gave sys.stdin a fileno(), which is sufficient to allow the input method to work. We should still reify this into the Console object at some point, but it's no longer a blocker.

@stuhood stuhood self-assigned this Mar 15, 2021
@stuhood stuhood added the pantsd label Mar 15, 2021
@stuhood
Copy link
Member Author

stuhood commented Mar 15, 2021

Aaactually, it looks like fileno is not sufficient to allow input to work. It also wants to use readline (in some cases).

@jsirois
Copy link
Contributor

jsirois commented Mar 15, 2021

If its useful and you haven't thought of it already, I quickly tried hacking this from the python side by wrapping sys.stdin in io.BufferedReader, then whacking a readable mole, then stopped - a few more moles at least. But may be quicker to experiment from that side in that way,

@stuhood
Copy link
Member Author

stuhood commented Mar 15, 2021

Yea, that's the path that I'm on as well. input appears to involve more magic than is strictly needed for this case (uses GNU readline, etc). Will keep trying that for a bit, and if all else fails, switch to a Console.input implementation based on sys.stdin.readline.

stuhood added a commit that referenced this issue Mar 16, 2021
…`. (#11703)

### Problem

The threadlocal implementation of `sys.stdin` added in #11536 did not expose enough methods to be used for `input`.

### Solution

Implement the methods needed for `input`, and wrap for use buffered text consumption.

### Result

Fixes #11398.

[ci skip-build-wheels]
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

Successfully merging a pull request may close this issue.

2 participants