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

notebook %reset magic fails with StdinNotImplementedError #1268

Closed
ivanov opened this issue Jan 14, 2012 · 4 comments · Fixed by #1288
Closed

notebook %reset magic fails with StdinNotImplementedError #1268

ivanov opened this issue Jan 14, 2012 · 4 comments · Fixed by #1288
Milestone

Comments

@ivanov
Copy link
Member

ivanov commented Jan 14, 2012

forgive me if this is a duplicate of the general issue of stdin not being implemented, but just wanted to report this bug on current git.

here's the trace:

 ---------------------------------------------------------------------------
 StdinNotImplementedError                  Traceback (most recent call last)
 /home/pi/code/py4science/2012-bootcamp/saturday/<ipython-input-22-7e9719c26028> in <module>()
 ----> 1 get_ipython().magic(u'reset')

 /home/pi/code/py4science/scipy2010/ipython/IPython/core/interactiveshell.pyc in magic(self, arg_s, next_input)
    1987                 self._magic_locals = sys._getframe(1).f_locals
    1988             with self.builtin_trap:
 -> 1989                 result = fn(magic_args)
    1990             # Ensure we're not keeping object references around:

    1991             self._magic_locals = {}

 /home/pi/code/py4science/scipy2010/ipython/IPython/core/magic.pyc in magic_reset(self, parameter_s)
     990         else:
     991             ans = self.shell.ask_yes_no(
 --> 992                 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ", default='n')
     993         if not ans:
     994             print 'Nothing done.'

 /home/pi/code/py4science/scipy2010/ipython/IPython/core/interactiveshell.pyc in ask_yes_no(self, prompt, default)
    2658         if self.quiet:
    2659             return True
 -> 2660         return ask_yes_no(prompt,default)
    2661 
    2662     def show_usage(self):

 /home/pi/code/py4science/scipy2010/ipython/IPython/utils/io.pyc in ask_yes_no(prompt, default)
     225     while ans not in answers.keys():
     226         try:
 --> 227             ans = raw_input(prompt+' ').lower()
     228             if not ans:  # response was an empty string
     229                 ans = default

 /home/pi/code/py4science/scipy2010/ipython/IPython/zmq/ipkernel.pyc in <lambda>(prompt)
     251             raw_input = lambda prompt='': self._raw_input(prompt, ident, parent)
     252         else:
 --> 253             raw_input = lambda prompt='' : self._no_raw_input()
     254 
     255         if py3compat.PY3:

 /home/pi/code/py4science/scipy2010/ipython/IPython/zmq/ipkernel.pyc in _no_raw_input(self)
     443         """Raise StdinNotImplentedError if active frontend doesn't support
     444         stdin."""
 --> 445         raise StdinNotImplementedError("raw_input was called, but this "
     446                                        "frontend does not support stdin.") 
     447 

 StdinNotImplementedError: raw_input was called, but this frontend does not support stdin.
@fperez
Copy link
Member

fperez commented Jan 14, 2012

Not a dupe; %reset shouldn't depend on stdin and should work in the notebook. So this is definitely a bug.

@fperez
Copy link
Member

fperez commented Jan 15, 2012

Actually never mind: it's halting because reset tries to ask the user for confirmation. In the notebook, you can use it with the -f option to avoid the prompt. There's really no way of knowing in advance whether stdin will be called, and since the kernel is agnostic to which client is controlling it, I don't think there's more we can do about this one. Closing (the real issue being stdin in the notebook).

@fperez fperez closed this as completed Jan 15, 2012
@takluyver
Copy link
Member

Could magic_reset() not simply catch the StdinNotImplementedError and continue as if it had got a 'yes'?

Or if we don't want to make that the default, it could print out a message saying "Use %reset -f to confirm". I think this would annoy more people than it helped, though.

@fperez
Copy link
Member

fperez commented Jan 16, 2012

On Sun, Jan 15, 2012 at 3:58 AM, Thomas
reply@reply.github.com
wrote:

Could magic_reset() not simply catch the StdinNotImplementedError and continue as if it had got a 'yes'?

Actually that's not a bad idea: %reset would simply assume that if
called from a frontend without stdin, the user actually meant it.

So I take my original point back, and I think Thomas' fix is both
fully sensible and very easy to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants