notebook %reset magic fails with StdinNotImplementedError #1268

Closed
ivanov opened this Issue Jan 14, 2012 · 4 comments

Comments

Projects
None yet
4 participants
@ivanov
Owner

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

This comment has been minimized.

Show comment Hide comment
@fperez

fperez Jan 14, 2012

Owner

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

Owner

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

This comment has been minimized.

Show comment Hide comment
@fperez

fperez Jan 15, 2012

Owner

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

Owner

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 Jan 15, 2012

@takluyver

This comment has been minimized.

Show comment Hide comment
@takluyver

takluyver Jan 15, 2012

Owner

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.

Owner

takluyver commented Jan 15, 2012

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

This comment has been minimized.

Show comment Hide comment
@fperez

fperez Jan 16, 2012

Owner

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.

Owner

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.

@takluyver takluyver reopened this Jan 18, 2012

takluyver added a commit to takluyver/ipython that referenced this issue Jan 18, 2012

minrk added a commit to minrk/ipython that referenced this issue Jan 28, 2012

@minrk minrk closed this Mar 7, 2012

yarikoptic pushed a commit to yarikoptic/ipython that referenced this issue May 2, 2014

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

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