Skip to content

Commit ac16da4

Browse files
committed
UnixConsole: raise EOFError in case input_fd is not a TTY
This is required for when the UnixConsole instance was created with stdin being a terminal, but then later not so anymore. E.g. having used pdbpp before pytest captures output, and then having a set_trace where pytest is capturing output, but the debugging plugin (which suspends capturing) is not active yet (pytest_load_initial_conftests). This will result in pdb raising `BdbQuit` then "correctly".
1 parent d1e0fd2 commit ac16da4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pyrepl/reader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,8 @@ def prepare(self):
478478
"""Get ready to run. Call restore when finished. You must not
479479
write to the console in between the calls to prepare and
480480
restore."""
481+
self.console.prepare()
481482
try:
482-
self.console.prepare()
483483
self.arg = None
484484
self.screeninfo = []
485485
self.finished = 0

pyrepl/unix_console.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,11 @@ def move_cursor(self, x, y):
354354

355355
def prepare(self):
356356
# per-readline preparations:
357-
self.__svtermstate = tcgetattr(self.input_fd)
357+
try:
358+
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
358362
raw = self.__svtermstate.copy()
359363
raw.iflag |= termios.ICRNL
360364
raw.iflag &= ~(termios.BRKINT | termios.INPCK |

0 commit comments

Comments
 (0)