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

keyboardinterrupt crashes gtk gui when gtk.set_interactive is not available #825

Closed
juliantaylor opened this issue Sep 29, 2011 · 8 comments
Labels
Milestone

Comments

@juliantaylor
Copy link
Contributor

older gtk versions do not have gtk.set_interactive available which causes ipython to "use our own ctypes version":
IPython/lib/inputhook.py

240         import gtk
241         try:
242             gtk.set_interactive(True)
243             self._current_gui = GUI_GTK
244         except AttributeError:
245             # For older versions of gtk, use our own ctypes version
246             from IPython.lib.inputhookgtk import inputhook_gtk
247             self.set_inputhook(inputhook_gtk)
248             self._current_gui = GUI_GTK

this alternative does not handle keyboard interrupts well:

# make ipython use alternative, e.g. by using old gtk version or by editing:
# sed -i -e "s/gtk.set_interactive/gtk.garrbage/" IPython/lib/inputhook.py

ipython --pylab="gtk"
IN[1]: ^C
KeyboardInterrupt    Python 2.7.2+: /home/jtaylor/chroots/python/bin/python
                                                   Thu Sep 29 23:56:04 2011
A problem occured executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/home/jtaylor/chroots/python/_ctypes/callbacks.c in 'calling callback function'()

/home/jtaylor/chroots/python/lib/python2.7/site-packages/IPython/lib/inputhookgtk.pyc in inputhook_gtk()
     18 
     19 import sys
     20 import gtk, gobject
     21 
     22 #-----------------------------------------------------------------------------
     23 # Code
     24 #-----------------------------------------------------------------------------
     25 
     26 
     27 def _main_quit(*args, **kwargs):
     28     gtk.main_quit()
     29     return False
     30 
     31 def inputhook_gtk():
     32     gobject.io_add_watch(sys.stdin, gobject.IO_IN, _main_quit)
---> 33     gtk.main()
     34     return 0
     35 

KeyboardInterrupt: 

**********************************************************************

Oops, ipython crashed. We do our best to make it stable, but...
@minrk
Copy link
Member

minrk commented Sep 29, 2011

Sometimes we need to double-catch interrupts with these gui event loops.

How did you encounter this? PyGTK 2.15.0 (I believe the first to include set_interactive) was released in 05/2009, which is rather old.

@juliantaylor
Copy link
Contributor Author

Most still supported distributions should have newer versions, but unfortunately I currently have to use a fedora 11 machine which has pygtk 2.14 :(

@cboos
Copy link
Contributor

cboos commented Oct 9, 2011

The "Oops, ipython crashed." seen above most certainly expands to:

...
Original exception was:
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 313, in 'calling callback function'
  ...

i.e. one can't raise (or let go through) an exception from a ctypes callback, inputhook_gtk here.
So at a minimum, a try: ... except KeyboardInterrupt: pass should be added there.

@fperez
Copy link
Member

fperez commented Dec 13, 2011

@juliantaylor, since you're the only one to be able to test any fixes for this (I don't have a machine with a pygtk old enough to see it), we'll have to wait on you for a fix. You could try the try/except solution suggested above by @cboos; if it works for you go ahead and submit a PR for this. As long as it doesn't cause any problems with newer pygtks, we'll be happy to include the fix.

I'm retargetting for 0.13, b/c we're basically at the point of releasing 0.12 and I only want to focus on critical issues that absolutely must go in before release, this doesn't quite meet that threshold.

@juliantaylor
Copy link
Contributor Author

has this issue been fixed in HEAD? I can't reproduce it anymore, but ctrl+c also does not work at all anymore

@juliantaylor
Copy link
Contributor Author

the crash was fixed with 0fc80df
that ctrl+c does not work at all like before is probably a different issue (or intentional change ?) as it affects also other backends on more up to date systems.

@fperez
Copy link
Member

fperez commented Dec 15, 2011

Wow, since when did Ctrl-C stop working??? That's a huge regression, and most certainly a blocker. I'll open a separate issue for that.

@fperez
Copy link
Member

fperez commented Jun 26, 2012

We got distracted by #1157, but it sounds like this can be closed. Is that right @juliantaylor? I have no way of reproducing this, and you said you weren't seeing it either. In the interest of expedient triage I'm closing it now, please ping for a reopen if you find evidence it's still an issue.

@fperez fperez closed this as completed Jun 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants