Issue #24489: ensure a previously set C errno doesn't disturb cmath.p… · pythoncapi/cpython@a72f0cd · GitHub
Skip to content

Commit a72f0cd

Browse files
committed
Issue python#24489: ensure a previously set C errno doesn't disturb cmath.polar().
2 parents 5376ba9 + 6bc217d commit a72f0cd

4 files changed

Lines changed: 58 additions & 11 deletions

File tree

Lib/test/test_cmath.py

Lines changed: 41 additions & 10 deletions

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Core and Builtins
2424
Library
2525
-------
2626

27+
- Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
28+
2729
- Issue #24408: Fixed AttributeError in measure() and metrics() methods of
2830
tkinter.Font.
2931

Modules/_testcapimodule.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,18 @@ raise_exception(PyObject *self, PyObject *args)
17951795
return NULL;
17961796
}
17971797

1798+
static PyObject *
1799+
set_errno(PyObject *self, PyObject *args)
1800+
{
1801+
int new_errno;
1802+
1803+
if (!PyArg_ParseTuple(args, "i:set_errno", &new_errno))
1804+
return NULL;
1805+
1806+
errno = new_errno;
1807+
Py_RETURN_NONE;
1808+
}
1809+
17981810
static PyObject *
17991811
test_set_exc_info(PyObject *self, PyObject *args)
18001812
{
@@ -3510,6 +3522,7 @@ test_PyTime_AsMicroseconds(PyObject *self, PyObject *args)
35103522
static PyMethodDef TestMethods[] = {
35113523
{"raise_exception", raise_exception, METH_VARARGS},
35123524
{"raise_memoryerror", (PyCFunction)raise_memoryerror, METH_NOARGS},
3525+
{"set_errno", set_errno, METH_VARARGS},
35133526
{"test_config", (PyCFunction)test_config, METH_NOARGS},
35143527
{"test_sizeof_c_types", (PyCFunction)test_sizeof_c_types, METH_NOARGS},
35153528
{"test_datetime_capi", test_datetime_capi, METH_NOARGS},

Modules/cmathmodule.c

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)