diff --git a/pyrepl/unix_console.py b/pyrepl/unix_console.py index 57fe48a..afd107d 100644 --- a/pyrepl/unix_console.py +++ b/pyrepl/unix_console.py @@ -356,9 +356,8 @@ def prepare(self): # per-readline preparations: try: self.__svtermstate = tcgetattr(self.input_fd) - except termios.error: # (25, 'Inappropriate ioctl for device') - # assert not os.fdopen(self.input_fd).isatty() - raise EOFError + except termios.error as exc: + raise EOFError("could not prepare fd %d: %s" % (self.input_fd, exc)) self._prepared = True raw = self.__svtermstate.copy() raw.iflag |= termios.ICRNL diff --git a/testing/test_unix_console.py b/testing/test_unix_console.py new file mode 100644 index 0000000..51bf874 --- /dev/null +++ b/testing/test_unix_console.py @@ -0,0 +1,12 @@ +import pytest + + +def test_eoferror(): + from pyrepl.unix_console import UnixConsole + + console = UnixConsole(f_in=99) + with pytest.raises( + EOFError, + match="^could not prepare fd 99: .*Bad file descriptor" + ): + console.prepare()