Python Paste


fixtypeerror

Fixes the vague error message that you get when calling a function with the wrong arguments.


Functions

f fix_type_error(exc_info, callable, varargs, kwargs) ...

Given an exception, this will test if the exception was due to a signature error, and annotate the error with better information if so.

Usage:

try:
    val = callable(*args, **kw)
except TypeError:
    exc_info = fix_type_error(None, callable, args, kw)
    raise exc_info[0], exc_info[1], exc_info[2]

f fix_call(callable, *args, **kw) ...

Call callable(*args, **kw) fixing any type errors that come out.

See the source for more information.