-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
DontReadFromInput
only throws IOError
when read
is being used.
pyrepl
for example would raise termios.error
when it tries to use tcgetattr
- it does not read
directly:
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/daniel/Vcs/pyrepl-git/pyrepl/reader.py", line 482, in prepare
INTERNALERROR> self.console.prepare()
INTERNALERROR> File "/home/daniel/Vcs/pyrepl-git/pyrepl/unix_console.py", line 357, in prepare
INTERNALERROR> self.__svtermstate = tcgetattr(self.input_fd)
INTERNALERROR> File "/home/daniel/Vcs/pyrepl-git/pyrepl/fancy_termios.py", line 34, in tcgetattr
INTERNALERROR> return TermState(termios.tcgetattr(fd))
INTERNALERROR> termios.error: (25, 'Inappropriate ioctl for device')
I've tried changing this to EOFError
, which I found more appropriate (https://github.com/blueyed/pyrepl/pull/7), but then noticed that this causes pytest to consider this to be a quitting-the-debugger event (same as Ctrl-d
).
This "silent" exit was confusing when I've noticed this while stepping to pytest itself, where it would run code with set_trace
and apparently capturing output around it (another/a different issue).
I think we should maybe not use Exit
for do_EOF
(via set_quit
), but only with do_quit
as a first step. This would also give the benefit of having Ctrl-d
work differently than q
(displaying a traceback, and test summaries).
Lines 704 to 738 in 2051e30
class DontReadFromInput(six.Iterator): | |
"""Temporary stub class. Ideally when stdin is accessed, the | |
capturing should be turned off, with possibly all data captured | |
so far sent to the screen. This should be configurable, though, | |
because in automated test runs it is better to crash than | |
hang indefinitely. | |
""" | |
encoding = None | |
def read(self, *args): | |
raise IOError("reading from stdin while output is captured") | |
readline = read | |
readlines = read | |
__next__ = read | |
def __iter__(self): | |
return self | |
def fileno(self): | |
raise UnsupportedOperation("redirected stdin is pseudofile, has no fileno()") | |
def isatty(self): | |
return False | |
def close(self): | |
pass | |
@property | |
def buffer(self): | |
if sys.version_info >= (3, 0): | |
return self | |
else: | |
raise AttributeError("redirected stdin has no attribute buffer") |