On Fri, 3 Nov 2000, Aaron Optimizer Digulla wrote:
> ------- test.py ---------------------
> from gtk import *
>
> def test (x, y):
> print x, y
> mainquit ()
>
> timeout_add (1.0, test)
>
> mainloop ()
> -------- test.py ----------
>
> Run this and you will get this message:
>
> --- output ------------------------
> TypeError: not enough parameters; expected 2, got 0
> --- output ------------------------
>
> The problem is that timeout_add() doesn't give Python any hints
> what it should print as traceback. I submitted this as a bug in
> Python but Guide said this is a bug in PyGTK and I should post
> this here. The solution is probably that timeout_add() must
> put a traceback in the newly created callback and print that
> in case of an error.
He is right, it isn't a bug in Python :)
The exception is being caught just after the callback finishes, rather
than propagating up the call stack. The traceback only contains
information about the frames that don't catch the exception.
You can get complete traceback info by turning on `fatal exceptions'. If
you turn this on, if an exception occurs within a signal or callback, the
main loop will be quit, and right back to the initial main loop call.
This can be turned on by defining the environment variable
PYGTK_FATAL_EXCEPTIONS to something non false (eg. 1). It checks the
environment variable through the os.environ dictionary, so you should be
able to set this from within your script if you want.
>
> James, can you have a look, please ? I have one of these in the
> program I'm currently working on and it's impossible to find :-(
> (no, it's not in timeout_add()).
James.
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk