Commit e3759ab
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 904aef9 commit e3759ab
2 files changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | | - | |
| 328 | + | |
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| |||
0 commit comments