Implement Structured Exception Handling (SEH) for _ctypes function calls
In CPython on windows, a function call is wrapped in a MSVC-specific construct like
#ifndef DONT_USE_SEH
__try {
#endif
#endif
ffi_call(&cif, (void *)pProc, resmem, avalues);
#ifdef MS_WIN32
#ifndef DONT_USE_SEH
}
__except (HandleException(GetExceptionInformation(),
&dwExceptionCode, &record)) {
;
}
#endif
This is tested for in ctypes.test.test_win32.py and the test currently crashes the interpreter during tests.
The place to implement this is somewhere around rpython.rlib.clibffi.py
where it calls ffi_call
and again. Perhaps we could add another value to the ffires
result from ffi_call
to indicate an exception should be raised, to work around the c-level call to SetException in CPython
To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information