Guilherme Polo <ggp...@gmail.com> added the comment: Ah.. number 2 is problematic. Before continuing lets reduce the previous WaitTest.py to this (which shows the same problems):
import Tkinter root = Tkinter.Tk() waitVar = Tkinter.BooleanVar() root.after(3000, lambda: waitVar.set(True)) root.wait_variable(waitVar) When you run this, it will schedule the call to this lambda to happen 3 seconds later, and will block on the wait_variable call. Now suppose you hit Ctrl-c while you are stuck into a Tcl_EvalObjv call (Tcl_EvalObjv will end up being called after invoking wait_variable). Python will not notice this Ctrl-c for now (we are on Tcl land now), but eventually the event you scheduled earlier is fired. PythonCmd is called to handle it, which will then call the anonymous func, but since you pressed Ctrl-c it will return NULL and PythonCmd will call PythonCmd_Error to handle it. PythonCmd_Error sets errInCmd to 1, saves the exception and returns an TCL_ERROR indicator, this causes tkerror to be called. tkerror is a function created in Tkinter.py, which does nothing so that previous saved exception is not used. Next what happens is that the lambda function didn't execute, the tk variable didn't change and you are still blocked on wait_variable (this situation seems normal to me). So what I did here, and I'm not sure if it would be accepted or not, was create a new function in _tkinter.c called Tkinter_PrintError (accessible through _tkinter._print_error) that restores the saved exception and prints it. Now you might ask why not raise it instead ? Martin that is on the nosy list will agree with me, I think. Raising an error at this point will cause an Tk dialog to popup and it won't contain a proper traceback (if done this way I did), which is annoying. Note that even though PythonCmd_Error set errInCmd to 1, it was never used because the mainloop wasn't running (it also wouldn't make much difference to put a root.mainloop() after wait_variable since we would be blocked before the mainloop started). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue978604> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com