@@ -173,24 +173,13 @@ typedef enum _WIN32_THREADSTATE {
173173#define THREAD_STATUS_GIL_REQUESTED (1 << 3)
174174#define THREAD_STATUS_HAS_EXCEPTION (1 << 4)
175175
176- /* Exception cause macro - chains context to existing exceptions in debug mode.
177- * This macro assumes an exception has already been set by the failing function.
178- * If no exception exists, this indicates a bug that should be fixed. */
179- #define set_exception_cause (unwinder , exc_type , message ) \
180- do { \
181- if (!PyErr_ExceptionMatches(PyExc_PermissionError)) { \
182- if (PyErr_Occurred()) { \
183- if (unwinder->debug) { \
184- /* Chain exception with context */ \
185- _PyErr_FormatFromCause (exc_type , "%s" , message ); \
186- } \
187- } else { \
188- /* BUG: Exception should have been set by caller */ \
189- /* Fallback prevents crash; assert catches bug in debug builds */ \
190- PyErr_SetString (exc_type , message ); \
191- assert (PyErr_Occurred () && "function returned -1 without setting exception" ); \
192- } \
193- } \
176+ /* Exception cause macro */
177+ #define set_exception_cause (unwinder , exc_type , message ) \
178+ do { \
179+ assert(PyErr_Occurred() && "function returned -1 without setting exception"); \
180+ if (unwinder->debug) { \
181+ _set_debug_exception_cause(exc_type, message); \
182+ } \
194183 } while (0)
195184
196185/* ============================================================================
0 commit comments