diff --git a/pyrepl/unix_console.py b/pyrepl/unix_console.py index 99aeb8c..a462b2e 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..e7a50b9 --- /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) as excinfo: + console.prepare() + assert excinfo.value.args == ( + "could not prepare fd 99: (9, 'Bad file descriptor')", + )