L
lallous
Hello,
Is there is a way, using the Python C api, to install an exception handler
that:
- will be triggered when an exception occurs
- analyze the reason of the exception
- correct the situation and try again (something like exception handling on
windows where the exception handler can retrieve the registers
context->faulting instruction->fix situation if needed->restart execution
from the same point)
Since I will be asked: "what are you trying to achieve?", this is what I
want:
func_call("hello") <- no exceptions, good code: function is defined and
called properly
SomeUndefinedFunction("x", "y") <- undefined function call will trigger an
exception. I want my python/C exception handler to inspect the reason of the
exception, if it was a call to an undefined function call then redirect the
execution to a certain method, say: ExecuteByName("SomeUndefinedFunction",
"x", "y")
I know if I create a small class with getattr hooked, what I want can be
achieved.
But can it be done otherwise (without using a class and instead relying on
exception handlers and correcting the exception)?
Regards,
Elias
Is there is a way, using the Python C api, to install an exception handler
that:
- will be triggered when an exception occurs
- analyze the reason of the exception
- correct the situation and try again (something like exception handling on
windows where the exception handler can retrieve the registers
context->faulting instruction->fix situation if needed->restart execution
from the same point)
Since I will be asked: "what are you trying to achieve?", this is what I
want:
func_call("hello") <- no exceptions, good code: function is defined and
called properly
SomeUndefinedFunction("x", "y") <- undefined function call will trigger an
exception. I want my python/C exception handler to inspect the reason of the
exception, if it was a call to an undefined function call then redirect the
execution to a certain method, say: ExecuteByName("SomeUndefinedFunction",
"x", "y")
I know if I create a small class with getattr hooked, what I want can be
achieved.
But can it be done otherwise (without using a class and instead relying on
exception handlers and correcting the exception)?
Regards,
Elias