object = Apply(exceptionHandler, func , args )

Calls a Python function, but traps Win32 exceptions.


exceptionHandler : object

An object which will be called when a win32 exception occurs.

func : object

The function call call under the protection of the Win32 exception handler.

args : tuple

Args for the function.


Calls the specified function in a manner similar to the built-in function apply(), but allows Win32 exceptions to be handled by Python. If a Win32 exception occurs calling the function, the specified exceptionHandler is called, and its return value determines the action taken.

Return value Description
Tuple of (exc_type, exc_value)This exception is raised to the Python caller of Apply() - This is conceptually similar to "raise exc_type, exc_value", although exception handlers must not themselves raise exceptions (see below).
IntegerMust be one of the win32 exception constants, and this value is returned to Win32. See the Win32 documentation for details.
NoneThe exception is considered not handled (ie, it is as if no exception handler exists). If a Python exception occurs in the Win32 exception handler, it is as if None were returned (ie, no tracebacks or other diagnostics are printed)