summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapi
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-03-07 21:27:46 (GMT)
committerGitHub <noreply@github.com>2023-03-07 21:27:46 (GMT)
commita33ca2ad1fcf857817cba505a788e15cf9d6ed0c (patch)
tree8717635b992632d1f3f95f27631f0085423d5423 /Modules/_testcapi
parent54060ae91da2df44b3f6e6c698694d40284687e9 (diff)
downloadcpython-a33ca2ad1fcf857817cba505a788e15cf9d6ed0c.zip
cpython-a33ca2ad1fcf857817cba505a788e15cf9d6ed0c.tar.gz
cpython-a33ca2ad1fcf857817cba505a788e15cf9d6ed0c.tar.bz2
gh-102493: fix normalization in PyErr_SetObject (#102502)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Modules/_testcapi')
-rw-r--r--Modules/_testcapi/exceptions.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/_testcapi/exceptions.c b/Modules/_testcapi/exceptions.c
index 43b88cc..a057521 100644
--- a/Modules/_testcapi/exceptions.c
+++ b/Modules/_testcapi/exceptions.c
@@ -79,6 +79,20 @@ make_exception_with_doc(PyObject *self, PyObject *args, PyObject *kwargs)
}
static PyObject *
+exc_set_object(PyObject *self, PyObject *args)
+{
+ PyObject *exc;
+ PyObject *obj;
+
+ if (!PyArg_ParseTuple(args, "OO:exc_set_object", &exc, &obj)) {
+ return NULL;
+ }
+
+ PyErr_SetObject(exc, obj);
+ return NULL;
+}
+
+static PyObject *
raise_exception(PyObject *self, PyObject *args)
{
PyObject *exc;
@@ -247,6 +261,7 @@ static PyMethodDef test_methods[] = {
PyDoc_STR("fatal_error(message, release_gil=False): call Py_FatalError(message)")},
{"make_exception_with_doc", _PyCFunction_CAST(make_exception_with_doc),
METH_VARARGS | METH_KEYWORDS},
+ {"exc_set_object", exc_set_object, METH_VARARGS},
{"raise_exception", raise_exception, METH_VARARGS},
{"raise_memoryerror", raise_memoryerror, METH_NOARGS},
{"set_exc_info", test_set_exc_info, METH_VARARGS},