Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix missing exception handling in :mod:`_remote_debugging` when ``debug=False``. The ``set_exception_cause`` macro now always sets an exception to satisfy the C API contract, fixing intermittent assertion failures. Exception chaining with ``debug=True`` is preserved. Patch by Taegyun Kim.
Comment thread
taegyunkim marked this conversation as resolved.
Outdated
13 changes: 10 additions & 3 deletions Modules/_remote_debugging/_remote_debugging.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern "C" {
#include "internal/pycore_interpframe.h" // FRAME_OWNED_BY_INTERPRETER
#include "internal/pycore_llist.h" // struct llist_node
#include "internal/pycore_long.h" // _PyLong_GetZero
#include "internal/pycore_pyerrors.h" // _PyErr_FormatFromCause
#include "internal/pycore_stackref.h" // Py_TAG_BITS
#include "../../Python/remote_debug.h"

Expand Down Expand Up @@ -174,9 +175,15 @@ typedef enum _WIN32_THREADSTATE {

/* Exception cause macro */
#define set_exception_cause(unwinder, exc_type, message) \
if (unwinder->debug) { \
_set_debug_exception_cause(exc_type, message); \
}
do { \
if (!PyErr_ExceptionMatches(PyExc_PermissionError)) { \
if (!PyErr_Occurred()) { \
PyErr_SetString(exc_type, message); \
} else if (unwinder->debug) { \
_PyErr_FormatFromCause(exc_type, "%s", message); \
} \
} \
} while (0)
Comment thread
taegyunkim marked this conversation as resolved.
Outdated

/* ============================================================================
* TYPE DEFINITIONS
Expand Down
Loading