Commit 1041a42
fix(vt100): treat OSError on add_reader as EOFError (macOS kqueue) (#2065)
`Vt100Input._attached_input` already raises `EOFError` when
`loop.add_reader(fd, ...)` fails with `PermissionError`, which is what
Linux's `EPollSelector` raises when stdin points at /dev/null.
macOS's `KqueueSelector` does not raise `PermissionError` for the same
class of "unpollable stdin" cases — it raises `OSError [Errno 22]
Invalid argument` (from `kqueue.control()`). This currently propagates
all the way up out of `Application.run()` and crashes any consumer that
expected the existing `EOFError` contract.
Reproducer (macOS):
python -c "from prompt_toolkit import prompt; prompt('> ')" \
0< /dev/null
Or any wrapper that launches a prompt_toolkit app with a non-TTY stdin
on macOS — e.g. spawned from another agent process that has reassigned
fd 0.
Treat both `PermissionError` and `OSError` from `add_reader` as
end-of-input and raise `EOFError`, so callers see the same exception
regardless of which selector backend asyncio picked.
Co-authored-by: mads <mads@local>1 parent 940af53 commit 1041a42
1 file changed
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| |||
0 commit comments