diff options
author | Carey Metcalfe <carey@cmetcalfe.ca> | 2023-12-21 01:46:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-21 01:46:41 (GMT) |
commit | a2dd0e7038ad65a2464541f91604524d871d98a7 (patch) | |
tree | 467a8bfa7aac6a5b3e4ae3c37e237732bd1fcd7d /Python | |
parent | 1ff02385944924db7e683a607da2882462594764 (diff) | |
download | cpython-a2dd0e7038ad65a2464541f91604524d871d98a7.zip cpython-a2dd0e7038ad65a2464541f91604524d871d98a7.tar.gz cpython-a2dd0e7038ad65a2464541f91604524d871d98a7.tar.bz2 |
gh-111375: Use `NULL` rather than `None` in the exception stack to indicate that an exception was handled (#113302)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bytecodes.c | 2 | ||||
-rw-r--r-- | Python/errors.c | 6 | ||||
-rw-r--r-- | Python/executor_cases.c.h | 2 | ||||
-rw-r--r-- | Python/generated_cases.c.h | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 82d7a71..29e1dab 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1100,7 +1100,7 @@ dummy_func( inst(POP_EXCEPT, (exc_value -- )) { _PyErr_StackItem *exc_info = tstate->exc_info; - Py_XSETREF(exc_info->exc_value, exc_value); + Py_XSETREF(exc_info->exc_value, exc_value == Py_None ? NULL : exc_value); } inst(RERAISE, (values[oparg], exc -- values[oparg])) { diff --git a/Python/errors.c b/Python/errors.c index ed5eec5..e5f176a 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -121,11 +121,11 @@ _PyErr_GetTopmostException(PyThreadState *tstate) _PyErr_StackItem *exc_info = tstate->exc_info; assert(exc_info); - while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) && - exc_info->previous_item != NULL) + while (exc_info->exc_value == NULL && exc_info->previous_item != NULL) { exc_info = exc_info->previous_item; } + assert(!Py_IsNone(exc_info->exc_value)); return exc_info; } @@ -592,7 +592,7 @@ PyErr_GetHandledException(void) void _PyErr_SetHandledException(PyThreadState *tstate, PyObject *exc) { - Py_XSETREF(tstate->exc_info->exc_value, Py_XNewRef(exc)); + Py_XSETREF(tstate->exc_info->exc_value, Py_XNewRef(exc == Py_None ? NULL : exc)); } void diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 7cc29c8..69adb20 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -806,7 +806,7 @@ PyObject *exc_value; exc_value = stack_pointer[-1]; _PyErr_StackItem *exc_info = tstate->exc_info; - Py_XSETREF(exc_info->exc_value, exc_value); + Py_XSETREF(exc_info->exc_value, exc_value == Py_None ? NULL : exc_value); stack_pointer += -1; break; } diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index e935f33..f94dc61 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -4567,7 +4567,7 @@ PyObject *exc_value; exc_value = stack_pointer[-1]; _PyErr_StackItem *exc_info = tstate->exc_info; - Py_XSETREF(exc_info->exc_value, exc_value); + Py_XSETREF(exc_info->exc_value, exc_value == Py_None ? NULL : exc_value); stack_pointer += -1; DISPATCH(); } |