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

Commit 6bc217d

Browse files
committed
Issue python#24489: ensure a previously set C errno doesn't disturb cmath.polar().
1 parent 03863d2 commit 6bc217d

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
@@ -60,6 +60,8 @@ Core and Builtins
6060
Library
6161
-------
6262

63+
- Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
64+
6365
- Issue #5633: Fixed timeit when the statement is a string and the setup is not.
6466

6567
- Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.

Modules/_testcapimodule.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,18 @@ raise_exception(PyObject *self, PyObject *args)
17831783
return NULL;
17841784
}
17851785

1786+
static PyObject *
1787+
set_errno(PyObject *self, PyObject *args)
1788+
{
1789+
int new_errno;
1790+
1791+
if (!PyArg_ParseTuple(args, "i:set_errno", &new_errno))
1792+
return NULL;
1793+
1794+
errno = new_errno;
1795+
Py_RETURN_NONE;
1796+
}
1797+
17861798
static PyObject *
17871799
test_set_exc_info(PyObject *self, PyObject *args)
17881800
{
@@ -3208,6 +3220,7 @@ pymarshal_read_object_from_file(PyObject* self, PyObject *args)
32083220
static PyMethodDef TestMethods[] = {
32093221
{"raise_exception", raise_exception, METH_VARARGS},
32103222
{"raise_memoryerror", (PyCFunction)raise_memoryerror, METH_NOARGS},
3223+
{"set_errno", set_errno, METH_VARARGS},
32113224
{"test_config", (PyCFunction)test_config, METH_NOARGS},
32123225
{"test_sizeof_c_types", (PyCFunction)test_sizeof_c_types, METH_NOARGS},
32133226
{"test_datetime_capi", test_datetime_capi, METH_NOARGS},

Modules/cmathmodule.c

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)