mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-102493: fix normalization in PyErr_SetObject (#102502)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
54060ae91d
commit
a33ca2ad1f
4 changed files with 56 additions and 4 deletions
|
@ -78,6 +78,20 @@ make_exception_with_doc(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
return PyErr_NewExceptionWithDoc(name, doc, base, dict);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue