Commit e69cd68
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 6a4528d commit e69cd68
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 | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
| 334 | + | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| |||
0 commit comments