Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdb: DontReadFromInput vs EOFError #5235

Closed
blueyed opened this issue May 8, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@blueyed
Copy link
Contributor

commented May 8, 2019

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).

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")

blueyed added a commit to blueyed/pytest that referenced this issue May 8, 2019

blueyed added a commit to blueyed/pytest that referenced this issue May 9, 2019

blueyed added a commit to blueyed/pytest that referenced this issue May 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.