--- 000/win32/src/win32apimodule.cpp 2019-07-18 09:05:08.224088200 +0300 +++ 001/win32/src/win32apimodule.cpp 2018-09-28 09:32:03.000000000 +0300 @@ -707,7 +707,7 @@ static PyObject *PyFindCloseChangeNotification(PyObject *self, PyObject *args) } // @pymethod string|win32api|FormatMessage|Returns an error message from the system error file. -static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) +__attribute__((optimize("O0"), noinline)) static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) { int errCode = 0; // @pyparm int|errCode|0|The error code to return the message for, If this value is 0, then GetLastError() is @@ -795,6 +795,7 @@ static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) { baccessviolation = TRUE; } + __except_end PyW32_END_ALLOW_THREADS } @@ -819,7 +818,7 @@ cleanup: } // @pymethod |win32api|FormatMessageW|Returns an error message from the system error file. -static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) +__attribute__((optimize("O0"), noinline)) static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) { int errCode = 0; // Accept just the error code @@ -902,6 +913,7 @@ static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) { baccessviolation = TRUE; } + __except_end PyW32_END_ALLOW_THREADS } @@ -5555,7 +5553,7 @@ static PyObject *PyApply(PyObject *self, PyObject *args) Py_XDECREF(exc_type); Py_XDECREF(exc_value); ret = NULL; - } + } __except_end return ret; // @comm Calls the specified function in a manner similar to // the built-in function apply(), but allows Win32 exceptions --- 000/com/win32com/src/include/PythonCOM.h 2020-06-13 08:39:03.000000000 +0300 +++ 001/com/win32com/src/include/PythonCOM.h 2020-06-20 13:10:05.609363700 +0300 @@ -111,8 +111,6 @@ #ifdef __MINGW32__ // Special Mingw32 considerations. #define NO_PYCOM_ENUMSTATPROPSTG -#define __try try -#define __except catch #include #endif // __MINGW32__ --- 000/com/win32comext/mapi/src/mapi.i 2020-06-13 08:39:03.000000000 +0300 +++ 001/com/win32comext/mapi/src/mapi.i 2020-06-20 13:10:05.609363700 +0300 @@ -129,6 +129,7 @@ PyWin_SetAPIError("MAPIUninitialize", ERROR_INVALID_HANDLE); rc = NULL; } + __except_end return rc; } --- 000/com/win32comext/shell/src/shell.cpp 2020-06-13 08:39:03.000000000 +0300 +++ 001/com/win32comext/shell/src/shell.cpp 2020-06-20 14:15:11.188333200 +0300 @@ -258,16 +258,13 @@ pidl = _ILNext(pidl); } } -#if defined(__MINGW32__) || defined(MAINWIN) - catch (...) -#else __except (EXCEPTION_EXECUTE_HANDLER) -#endif { Py_DECREF(ret); PyErr_SetString(PyExc_ValueError, "This string is an invalid PIDL (win32 exception unpacking)"); ret = NULL; } + __except_end if (bFreeSystemPIDL) CoTaskMemFree((void *)pidl_free); return ret;