-
-
Notifications
You must be signed in to change notification settings - Fork 32k
GH-103929: handle long input lines with PyOS_InputHook #103931
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
base: main
Are you sure you want to change the base?
Conversation
a63c908
to
1e6fc5b
Compare
The usual way to test a C API call directly is add a method to the |
@brandtbucher: Maybe you have enough context to review this since you've been in readline-adjacent things lately? |
I'll take a look |
1e6fc5b
to
e3759ab
Compare
rebased to handle conflicts with the sub-processor work. |
e3759ab
to
e69cd68
Compare
Rebased again. |
e69cd68
to
281588a
Compare
281588a
to
5f76a95
Compare
@brandtbucher did you ever get a chance to review this one? |
If: - stdin is in line buffer mode - the readline module is not loaded - not on windows - a GUI toolkit has installd PyOS_InputHook Then, if the user enters lines longer than 98 characters into `input`: - user calls `input(...)` - user types/pastes a line longer than 98 characters + 1 newline - PyOS_InputHook returns - the first 99 characters are returned - the last character is not a new line so we go back to my_fgets - the PyOS_InputHook blocks because despite there being value in the buffer, stdin does not flag itself as ready to be read again - user hits enter again and to finish reading the input - the extra new line comes out the next time the user calls input This fixes this bug by passing the currently read number of characters to `my_fgets` to skip the input hook when reading out a long buffer. closes python#103929
5f76a95
to
c433296
Compare
@pablogsal, @ambv: If I understand correctly, users are more likely to hit this bug in 3.14 since the new REPL doesn't use readline. Should we try to get this into the next 3.14 beta? |
This fix doesn't apply to the new REPL, so I don't think how this PR could help here |
Got it. My bad. |
@pablogsal Does that mean the new REPL should/will not have this 100 char limit while |
The bug that is fixed is in the readline-replacement implementation that Python carries, not in the input hooks, so if there are bugs in the new repl with long lines, they will be different bugs ;) |
I'll take that as a solid maybe ;). Will report if I find similar long-line bugs with active input hooks. Update: re-reading, it seems you mean the bug remains, but that the new REPL has worked around it in another way. Those of us using input-based REPL's the still need this fix. |
If:
Then, if the user enters lines longer than 98 characters into
input
:input(...)
This fixes this bug by passing the currently read number of characters to
my_fgets
to skip the input hook when reading out a long buffer.closes #103929
Qustions: