-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
bpo-14916: use specified tokenizer fd for file input #22190
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
Conversation
Hi, @pmp-p for the contribution. I will try to review the issue and the PR in the following fsyd. Could you please add some test that exercises this meanwhile? |
Also, please add a NEWS entry describing the fix |
I think that "interactive" implies that I'm still not sure if the blocking issue exists (see https://bugs.python.org/issue14916#msg184410), but it seems like the interactive execution should really use separate input and output descriptors, with a target use-case being a PTY descriptor that's been duplicated. Since that might require a lot of changes, I think a sufficient compromise would be to use (BTW, I have no say in the approval of this PR; I'm just the one who originally created https://bugs.python.org/issue14916.) |
@pablogsal , here's the test i use :
|
attaching file because it seems the bevedere-bot parser will modify code blocks it should not @ta0kira, i'm just trying here to fix the obvious parser bug, my use case does not use PTY so i don't know the side effects you may have encountered. I concur, actual repl adapters are weak for some use cases, ideally there should be one with three fd in ( line based) / out / err + an event source ( character based ) but afaik the asyncio shell from 3.8+ is tending toward that. |
@pablogsal sorry to bother pinging you, but that |
As @JulienPalard pointed it out, I don't think there should be an implicit fallback to stdin but it was in original PR. It would be nice to have any reviewer's advice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (but the space).
Tested on master. It make sense to me because the fd is given to PyParser_ASTFromFileObject up to PyTokenizer_FromFile which stores it in tok->fp
.
Also on line 835 there's a similar condition : read from the file if tok->fp is not null, else read from stdin.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Co-authored-by: Julien Palard <julien@palard.fr>
I have made the requested changes; please review again |
Thanks for making the requested changes! @JulienPalard: please review the changes made to this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still missing an automated test. Please, include one in the test suite.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@pablogsal sorry, i don't know how to test C-API from cpython testsuite on official platforms, i'm just a embedding user of it. Also the only time i had to spend was on the automated C linux above. |
Co-authored-by: Itay Elbirt <anotahacou@gmail.com>
Fix the compiler warning: format specifies type `wint_t` (aka `int`) but the argument has type `unsigned int`
The marker was added to the language in 3.8 and 3.7 only gets security patches.
@pablogsal, sorry i failed to rebase to main, so i recreated #22190 (comment) > PyRun_InteractiveOne\*() functions allow to explicitily set fd instead of stdin. but stdin was hardcoded in readline call. > This patch does not fix target file for prompt unlike original bpo one : prompt fd is unrelated to tokenizer source which could be read only. It is more of a bugfix regarding the docs : actual documentation say "prompt the user" so one would expect prompt to go on stdout not a file for both PyRun_InteractiveOne\*() and PyRun_InteractiveLoop\*(). Automerge-Triggered-By: GH:pablogsal
PyRun_InteractiveOne*() functions allow to explicitily set fd instead of stdin.
but stdin was hardcoded in readline call.
This patch does not fix target file for prompt unlike original bpo one : prompt fd is unrelated to tokenizer source which could be read only.
Also actual documentation say "prompt the user" so one would expect prompt to go on stdout not a file for both PyRun_InteractiveOne*() and PyRun_InteractiveLoop*().
EDIT/ to be clear this is a 🔴type-bugfix🔴
https://bugs.python.org/issue14916