summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorapaz <aarpazdera@gmail.com>2023-11-27 21:13:27 (GMT)
committerGitHub <noreply@github.com>2023-11-27 21:13:27 (GMT)
commit8f71b349de1ff2b11223ff7a8241c62a5a932339 (patch)
tree8a82a58f300111f34a538f8df22e6c9e82409f53 /Python
parent4dcfd02bed0d7958703ef44baa79a4a98475be2e (diff)
downloadcpython-8f71b349de1ff2b11223ff7a8241c62a5a932339.zip
cpython-8f71b349de1ff2b11223ff7a8241c62a5a932339.tar.gz
cpython-8f71b349de1ff2b11223ff7a8241c62a5a932339.tar.bz2
gh-112217: Add check to call result for `do_raise()` where cause is a type. (#112216)
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 76ab5df..def75fd 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1920,6 +1920,13 @@ do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause)
fixed_cause = _PyObject_CallNoArgs(cause);
if (fixed_cause == NULL)
goto raise_error;
+ if (!PyExceptionInstance_Check(fixed_cause)) {
+ _PyErr_Format(tstate, PyExc_TypeError,
+ "calling %R should have returned an instance of "
+ "BaseException, not %R",
+ cause, Py_TYPE(fixed_cause));
+ goto raise_error;
+ }
Py_DECREF(cause);
}
else if (PyExceptionInstance_Check(cause)) {