From 6bc217dd3d43763e62b413e75ddaeb7d30e1b451 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 23 Jun 2015 14:31:11 +0200 Subject: Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar(). --- Modules/cmathmodule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Modules/cmathmodule.c') 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(); -- cgit v1.2.1