summaryrefslogtreecommitdiff
path: root/Modules/cmathmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2015-06-23 14:31:11 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2015-06-23 14:31:11 +0200
commit2e3ae526a83477bb77bba712f432b81fee3cb8db (patch)
tree5e69c9998a80c0bded48dc45d653e494974402d4 /Modules/cmathmodule.c
parent43b47fee7c4abbf3da8d1eb9cfb0265adcaf9b32 (diff)
downloadcpython-2e3ae526a83477bb77bba712f432b81fee3cb8db.tar.gz
Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
Diffstat (limited to 'Modules/cmathmodule.c')
-rw-r--r--Modules/cmathmodule.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c
index eb2853cedd..b341c343e1 100644
--- a/Modules/cmathmodule.c
+++ b/Modules/cmathmodule.c
@@ -941,9 +941,10 @@ cmath_polar(PyObject *self, PyObject *args)
double r, phi;
if (!PyArg_ParseTuple(args, "D:polar", &z))
return NULL;
+ errno = 0;
PyFPE_START_PROTECT("polar function", return 0)
phi = c_atan2(z); /* should not cause any exception */
- r = c_abs(z); /* sets errno to ERANGE on overflow; otherwise 0 */
+ r = c_abs(z); /* sets errno to ERANGE on overflow */
PyFPE_END_PROTECT(r)
if (errno != 0)
return math_error();