Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 7ce3b78..5896e48 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1373,6 +1373,17 @@
return NULL;
}
+static PyObject *
+set_errno(PyObject *self, PyObject *args)
+{
+ int new_errno;
+
+ if (!PyArg_ParseTuple(args, "i:set_errno", &new_errno))
+ return NULL;
+
+ errno = new_errno;
+ Py_RETURN_NONE;
+}
static int test_run_counter = 0;
@@ -2032,6 +2043,7 @@
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
+ {"set_errno", set_errno, METH_VARARGS},
{"test_config", (PyCFunction)test_config, METH_NOARGS},
{"test_datetime_capi", test_datetime_capi, METH_NOARGS},
{"test_list_api", (PyCFunction)test_list_api, METH_NOARGS},