Ok, thanks for the input (especially for the trace function ! That's
something I was always missing :-)

Here is my current solution: I defined a wrapper function which is
called instead of the real function and that wrapper prints a meaningful
error:

def wrapper (*args, **kw):
    '''Small helper to find the cause of spurious TypeErrors (expected X
    arguments, got Y without trace).'''

    # wrapper() itself must not expect any arguments because that could
    # again cause TypeErrors.
    if len (args) == 0:
        raise 'wrapper called without arguments'
    else:
        try:
            apply (args[0], args[1:], kw)
        except TypeError, e:
            import types
            if type (args[0]) == types.FunctionType:
                code = args[0].func_code
                f = "%s %s:%d" % (
                    args[0].__name__,
                    code.co_filename,
                    code.co_firstlineno,
                )
            else:
                f = str (args[0])
            print f, args[1:], kw
            raise 'Error calling %s(%s,%s): %s' % (
                f, args[1:], kw, str (e),
            )
        except:
            print args, kw
            raise

The check above probable needs some extension when methods should be called
but I'm too lazy right now to implement all possible callables (and I
believe the release-early-release-often idea of OS :-)

-- 
==============================================
Sowatec AG,       CH-8330 Pf�ffikon (ZH)
Witzbergstr. 7,   http://www.sowatec.com
Tel: +41-(0)1-952 55 55
Fax: +41-(0)1-952 55 66
----------------------------------------------
Aaron "Optimizer" Digulla, [EMAIL PROTECTED]
==============================================


_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to