Commit 1d13392
committed
GH-103929: handle long input lines with PyOS_InputHook
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 #1039291 parent 9a87ce8 commit 1d13392
2 files changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | | - | |
| 336 | + | |
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| |||
0 commit comments