summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-11-20 01:51:30 (GMT)
committerGitHub <noreply@github.com>2019-11-20 01:51:30 (GMT)
commitbe143ec99674ba38c5811f34cdb85ef39c2dc8f8 (patch)
treefb6f916b483c7dd7506d92899604cd17a4344e0d /Modules
parent01b1cc12e7c6a3d6a3d27ba7c731687d57aae92a (diff)
downloadcpython-be143ec99674ba38c5811f34cdb85ef39c2dc8f8.zip
cpython-be143ec99674ba38c5811f34cdb85ef39c2dc8f8.tar.gz
cpython-be143ec99674ba38c5811f34cdb85ef39c2dc8f8.tar.bz2
bpo-38835: Don't use PyFPE_START_PROTECT and PyFPE_END_PROTECT (GH-17231)
The PyFPE_START_PROTECT() and PyFPE_END_PROTECT() macros are empty: they have been doing nothing for the last year (since commit 735ae8d139a673b30b321dc10acfd3d14f0d633b), so stop using them.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_tkinter.c2
-rw-r--r--Modules/clinic/cmathmodule.c.h47
-rw-r--r--Modules/cmathmodule.c13
-rw-r--r--Modules/mathmodule.c19
4 files changed, 18 insertions, 63 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 40d2ed7..4f7d1b7 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -2166,11 +2166,9 @@ _tkinter_tkapp_exprdouble_impl(TkappObject *self, const char *s)
CHECK_STRING_LENGTH(s);
CHECK_TCL_APPARTMENT;
- PyFPE_START_PROTECT("Tkapp_ExprDouble", return 0)
ENTER_TCL
retval = Tcl_ExprDouble(Tkapp_Interp(self), s, &v);
ENTER_OVERLAP
- PyFPE_END_PROTECT(retval)
if (retval == TCL_ERROR)
res = Tkinter_Error(self);
else
diff --git a/Modules/clinic/cmathmodule.c.h b/Modules/clinic/cmathmodule.c.h
index 81a8437..4b6653a 100644
--- a/Modules/clinic/cmathmodule.c.h
+++ b/Modules/clinic/cmathmodule.c.h
@@ -26,9 +26,8 @@ cmath_acos(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_acos_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -69,9 +68,8 @@ cmath_acosh(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_acosh_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -112,9 +110,8 @@ cmath_asin(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_asin_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -155,9 +152,8 @@ cmath_asinh(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_asinh_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -198,9 +194,8 @@ cmath_atan(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_atan_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -241,9 +236,8 @@ cmath_atanh(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_atanh_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -284,9 +278,8 @@ cmath_cos(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_cos_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -327,9 +320,8 @@ cmath_cosh(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_cosh_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -370,9 +362,8 @@ cmath_exp(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_exp_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -413,9 +404,8 @@ cmath_log10(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_log10_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -456,9 +446,8 @@ cmath_sin(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_sin_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -499,9 +488,8 @@ cmath_sinh(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_sinh_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -542,9 +530,8 @@ cmath_sqrt(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_sqrt_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -585,9 +572,8 @@ cmath_tan(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_tan_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -628,9 +614,8 @@ cmath_tanh(PyObject *module, PyObject *arg)
goto exit;
}
/* modifications for z */
- errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
+ errno = 0;
_return_value = cmath_tanh_impl(module, z);
- PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -968,4 +953,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=3edc4484b10ae752 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=353347db2e808e0d input=a9049054013a1b77]*/
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c
index 02c09bb..8b21dec 100644
--- a/Modules/cmathmodule.c
+++ b/Modules/cmathmodule.c
@@ -17,7 +17,7 @@ module cmath
/*[python input]
class Py_complex_protected_converter(Py_complex_converter):
def modify(self):
- return 'errno = 0; PyFPE_START_PROTECT("complex function", goto exit);'
+ return 'errno = 0;'
class Py_complex_protected_return_converter(CReturnConverter):
@@ -26,7 +26,6 @@ class Py_complex_protected_return_converter(CReturnConverter):
def render(self, function, data):
self.declare(data)
data.return_conversion.append("""
-PyFPE_END_PROTECT(_return_value);
if (errno == EDOM) {
PyErr_SetString(PyExc_ValueError, "math domain error");
goto exit;
@@ -40,7 +39,7 @@ else {
}
""".strip())
[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=345daa075b1028e7]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=8b27adb674c08321]*/
#if (FLT_RADIX != 2 && FLT_RADIX != 16)
#error "Modules/cmathmodule.c expects FLT_RADIX to be 2 or 16"
@@ -960,7 +959,6 @@ cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj)
Py_complex y;
errno = 0;
- PyFPE_START_PROTECT("complex function", return 0)
x = c_log(x);
if (y_obj != NULL) {
y = PyComplex_AsCComplex(y_obj);
@@ -970,7 +968,6 @@ cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj)
y = c_log(y);
x = _Py_c_quot(x, y);
}
- PyFPE_END_PROTECT(x)
if (errno != 0)
return math_error();
return PyComplex_FromCComplex(x);
@@ -1008,9 +1005,7 @@ cmath_phase_impl(PyObject *module, Py_complex z)
double phi;
errno = 0;
- PyFPE_START_PROTECT("arg function", return 0)
phi = c_atan2(z);
- PyFPE_END_PROTECT(phi)
if (errno != 0)
return math_error();
else
@@ -1035,10 +1030,8 @@ cmath_polar_impl(PyObject *module, Py_complex z)
double r, phi;
errno = 0;
- PyFPE_START_PROTECT("polar function", return 0)
phi = c_atan2(z); /* should not cause any exception */
r = _Py_c_abs(z); /* sets errno to ERANGE on overflow */
- PyFPE_END_PROTECT(r)
if (errno != 0)
return math_error();
else
@@ -1074,7 +1067,6 @@ cmath_rect_impl(PyObject *module, double r, double phi)
{
Py_complex z;
errno = 0;
- PyFPE_START_PROTECT("rect function", return 0)
/* deal with special values */
if (!Py_IS_FINITE(r) || !Py_IS_FINITE(phi)) {
@@ -1116,7 +1108,6 @@ cmath_rect_impl(PyObject *module, double r, double phi)
errno = 0;
}
- PyFPE_END_PROTECT(z)
if (errno != 0)
return math_error();
else
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index eaaeedb..e60e19b 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -936,9 +936,7 @@ math_1_to_whatever(PyObject *arg, double (*func) (double),
if (x == -1.0 && PyErr_Occurred())
return NULL;
errno = 0;
- PyFPE_START_PROTECT("in math_1", return 0);
r = (*func)(x);
- PyFPE_END_PROTECT(r);
if (Py_IS_NAN(r) && !Py_IS_NAN(x)) {
PyErr_SetString(PyExc_ValueError,
"math domain error"); /* invalid arg */
@@ -972,9 +970,7 @@ math_1a(PyObject *arg, double (*func) (double))
if (x == -1.0 && PyErr_Occurred())
return NULL;
errno = 0;
- PyFPE_START_PROTECT("in math_1a", return 0);
r = (*func)(x);
- PyFPE_END_PROTECT(r);
if (errno && is_error(r))
return NULL;
return PyFloat_FromDouble(r);
@@ -1025,9 +1021,7 @@ math_2(PyObject *const *args, Py_ssize_t nargs,
if ((x == -1.0 || y == -1.0) && PyErr_Occurred())
return NULL;
errno = 0;
- PyFPE_START_PROTECT("in math_2", return 0);
r = (*func)(x, y);
- PyFPE_END_PROTECT(r);
if (Py_IS_NAN(r)) {
if (!Py_IS_NAN(x) && !Py_IS_NAN(y))
errno = EDOM;
@@ -1340,8 +1334,6 @@ math_fsum(PyObject *module, PyObject *seq)
if (iter == NULL)
return NULL;
- PyFPE_START_PROTECT("fsum", Py_DECREF(iter); return NULL)
-
for(;;) { /* for x in iterable */
assert(0 <= n && n <= m);
assert((m == NUM_PARTIALS && p == ps) ||
@@ -1436,7 +1428,6 @@ math_fsum(PyObject *module, PyObject *seq)
sum = PyFloat_FromDouble(hi);
_fsum_error:
- PyFPE_END_PROTECT(hi)
Py_DECREF(iter);
if (p != ps)
PyMem_Free(p);
@@ -2111,9 +2102,7 @@ math_frexp_impl(PyObject *module, double x)
i = 0;
}
else {
- PyFPE_START_PROTECT("in math_frexp", return 0);
x = frexp(x, &i);
- PyFPE_END_PROTECT(x);
}
return Py_BuildValue("(di)", x, i);
}
@@ -2168,9 +2157,7 @@ math_ldexp_impl(PyObject *module, double x, PyObject *i)
errno = 0;
} else {
errno = 0;
- PyFPE_START_PROTECT("in math_ldexp", return 0);
r = ldexp(x, (int)exp);
- PyFPE_END_PROTECT(r);
if (Py_IS_INFINITY(r))
errno = ERANGE;
}
@@ -2207,9 +2194,7 @@ math_modf_impl(PyObject *module, double x)
}
errno = 0;
- PyFPE_START_PROTECT("in math_modf", return 0);
x = modf(x, &y);
- PyFPE_END_PROTECT(x);
return Py_BuildValue("(dd)", x, y);
}
@@ -2356,9 +2341,7 @@ math_fmod_impl(PyObject *module, double x, double y)
if (Py_IS_INFINITY(y) && Py_IS_FINITE(x))
return PyFloat_FromDouble(x);
errno = 0;
- PyFPE_START_PROTECT("in math_fmod", return 0);
r = fmod(x, y);
- PyFPE_END_PROTECT(r);
if (Py_IS_NAN(r)) {
if (!Py_IS_NAN(x) && !Py_IS_NAN(y))
errno = EDOM;
@@ -2646,9 +2629,7 @@ math_pow_impl(PyObject *module, double x, double y)
else {
/* let libm handle finite**finite */
errno = 0;
- PyFPE_START_PROTECT("in math_pow", return 0);
r = pow(x, y);
- PyFPE_END_PROTECT(r);
/* a NaN result should arise only from (-ve)**(finite
non-integer); in this case we want to raise ValueError. */
if (!Py_IS_FINITE(r)) {