SIGN IN SIGN UP

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>
M
madsmmfu committed
1041a423f86b09af6ffefe0aa6ac117e8f3b03bc
Parent: 940af53
Committed by GitHub <noreply@github.com> on 5/14/2026, 9:43:58 AM