Skip to content

Commit 71560a1

Browse files
committed
improve, add test
1 parent 4e06dd5 commit 71560a1

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pyrepl/unix_console.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,8 @@ def prepare(self):
356356
# per-readline preparations:
357357
try:
358358
self.__svtermstate = tcgetattr(self.input_fd)
359-
except termios.error: # (25, 'Inappropriate ioctl for device')
360-
# assert not os.fdopen(self.input_fd).isatty()
361-
raise EOFError
359+
except termios.error as exc:
360+
raise EOFError("could not prepare fd %d: %s" % (self.input_fd, exc))
362361
self._prepared = True
363362
raw = self.__svtermstate.copy()
364363
raw.iflag |= termios.ICRNL

testing/test_unix_console.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pytest
2+
3+
4+
def test_eoferror():
5+
from pyrepl.unix_console import UnixConsole
6+
7+
console = UnixConsole(f_in=99)
8+
with pytest.raises(EOFError) as excinfo:
9+
console.prepare()
10+
assert excinfo.value.args == (
11+
"could not prepare fd 99: (9, 'Bad file descriptor')",
12+
)

0 commit comments

Comments
 (0)