diff options
author | Victor Stinner <vstinner@python.org> | 2019-11-20 01:51:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 01:51:30 (GMT) |
commit | be143ec99674ba38c5811f34cdb85ef39c2dc8f8 (patch) | |
tree | fb6f916b483c7dd7506d92899604cd17a4344e0d /Objects | |
parent | 01b1cc12e7c6a3d6a3d27ba7c731687d57aae92a (diff) | |
download | cpython-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 'Objects')
-rw-r--r-- | Objects/complexobject.c | 12 | ||||
-rw-r--r-- | Objects/floatobject.c | 20 |
2 files changed, 0 insertions, 32 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c index a49da40..367752d 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -466,9 +466,7 @@ complex_add(PyObject *v, PyObject *w) Py_complex a, b; TO_COMPLEX(v, a); TO_COMPLEX(w, b); - PyFPE_START_PROTECT("complex_add", return 0) result = _Py_c_sum(a, b); - PyFPE_END_PROTECT(result) return PyComplex_FromCComplex(result); } @@ -479,9 +477,7 @@ complex_sub(PyObject *v, PyObject *w) Py_complex a, b; TO_COMPLEX(v, a); TO_COMPLEX(w, b); - PyFPE_START_PROTECT("complex_sub", return 0) result = _Py_c_diff(a, b); - PyFPE_END_PROTECT(result) return PyComplex_FromCComplex(result); } @@ -492,9 +488,7 @@ complex_mul(PyObject *v, PyObject *w) Py_complex a, b; TO_COMPLEX(v, a); TO_COMPLEX(w, b); - PyFPE_START_PROTECT("complex_mul", return 0) result = _Py_c_prod(a, b); - PyFPE_END_PROTECT(result) return PyComplex_FromCComplex(result); } @@ -505,10 +499,8 @@ complex_div(PyObject *v, PyObject *w) Py_complex a, b; TO_COMPLEX(v, a); TO_COMPLEX(w, b); - PyFPE_START_PROTECT("complex_div", return 0) errno = 0; quot = _Py_c_quot(a, b); - PyFPE_END_PROTECT(quot) if (errno == EDOM) { PyErr_SetString(PyExc_ZeroDivisionError, "complex division by zero"); return NULL; @@ -547,7 +539,6 @@ complex_pow(PyObject *v, PyObject *w, PyObject *z) PyErr_SetString(PyExc_ValueError, "complex modulo"); return NULL; } - PyFPE_START_PROTECT("complex_pow", return 0) errno = 0; exponent = b; int_exponent = (long)exponent.real; @@ -556,7 +547,6 @@ complex_pow(PyObject *v, PyObject *w, PyObject *z) else p = _Py_c_pow(a, exponent); - PyFPE_END_PROTECT(p) Py_ADJUST_ERANGE2(p.real, p.imag); if (errno == EDOM) { PyErr_SetString(PyExc_ZeroDivisionError, @@ -604,9 +594,7 @@ complex_abs(PyComplexObject *v) { double result; - PyFPE_START_PROTECT("complex_abs", return 0) result = _Py_c_abs(v->cval); - PyFPE_END_PROTECT(result) if (errno == ERANGE) { PyErr_SetString(PyExc_OverflowError, diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 3f9bbde..20a5155 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -506,7 +506,6 @@ float_richcompare(PyObject *v, PyObject *w, int op) goto Unimplemented; Compare: - PyFPE_START_PROTECT("richcompare", return NULL) switch (op) { case Py_EQ: r = i == j; @@ -527,7 +526,6 @@ float_richcompare(PyObject *v, PyObject *w, int op) r = i > j; break; } - PyFPE_END_PROTECT(r) return PyBool_FromLong(r); Unimplemented: @@ -546,9 +544,7 @@ float_add(PyObject *v, PyObject *w) double a,b; CONVERT_TO_DOUBLE(v, a); CONVERT_TO_DOUBLE(w, b); - PyFPE_START_PROTECT("add", return 0) a = a + b; - PyFPE_END_PROTECT(a) return PyFloat_FromDouble(a); } @@ -558,9 +554,7 @@ float_sub(PyObject *v, PyObject *w) double a,b; CONVERT_TO_DOUBLE(v, a); CONVERT_TO_DOUBLE(w, b); - PyFPE_START_PROTECT("subtract", return 0) a = a - b; - PyFPE_END_PROTECT(a) return PyFloat_FromDouble(a); } @@ -570,9 +564,7 @@ float_mul(PyObject *v, PyObject *w) double a,b; CONVERT_TO_DOUBLE(v, a); CONVERT_TO_DOUBLE(w, b); - PyFPE_START_PROTECT("multiply", return 0) a = a * b; - PyFPE_END_PROTECT(a) return PyFloat_FromDouble(a); } @@ -587,9 +579,7 @@ float_div(PyObject *v, PyObject *w) "float division by zero"); return NULL; } - PyFPE_START_PROTECT("divide", return 0) a = a / b; - PyFPE_END_PROTECT(a) return PyFloat_FromDouble(a); } @@ -605,7 +595,6 @@ float_rem(PyObject *v, PyObject *w) "float modulo"); return NULL; } - PyFPE_START_PROTECT("modulo", return 0) mod = fmod(vx, wx); if (mod) { /* ensure the remainder has the same sign as the denominator */ @@ -619,7 +608,6 @@ float_rem(PyObject *v, PyObject *w) it has the same sign as the denominator. */ mod = copysign(0.0, wx); } - PyFPE_END_PROTECT(mod) return PyFloat_FromDouble(mod); } @@ -634,7 +622,6 @@ float_divmod(PyObject *v, PyObject *w) PyErr_SetString(PyExc_ZeroDivisionError, "float divmod()"); return NULL; } - PyFPE_START_PROTECT("divmod", return 0) mod = fmod(vx, wx); /* fmod is typically exact, so vx-mod is *mathematically* an exact multiple of wx. But this is fp arithmetic, and fp @@ -666,7 +653,6 @@ float_divmod(PyObject *v, PyObject *w) /* div is zero - get the same sign as the true quotient */ floordiv = copysign(0.0, vx / wx); /* zero w/ sign of vx/wx */ } - PyFPE_END_PROTECT(floordiv) return Py_BuildValue("(dd)", floordiv, mod); } @@ -793,9 +779,7 @@ float_pow(PyObject *v, PyObject *w, PyObject *z) * the platform pow to step in and do the rest. */ errno = 0; - PyFPE_START_PROTECT("pow", return NULL) ix = pow(iv, iw); - PyFPE_END_PROTECT(ix) Py_ADJUST_ERANGE1(ix); if (negate_result) ix = -ix; @@ -849,9 +833,7 @@ float_is_integer_impl(PyObject *self) if (!Py_IS_FINITE(x)) Py_RETURN_FALSE; errno = 0; - PyFPE_START_PROTECT("is_integer", return NULL) o = (floor(x) == x) ? Py_True : Py_False; - PyFPE_END_PROTECT(x) if (errno != 0) { PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : PyExc_ValueError); @@ -1567,9 +1549,7 @@ float_as_integer_ratio_impl(PyObject *self) return NULL; } - PyFPE_START_PROTECT("as_integer_ratio", goto error); float_part = frexp(self_double, &exponent); /* self_double == float_part * 2**exponent exactly */ - PyFPE_END_PROTECT(float_part); for (i=0; i<300 && float_part != floor(float_part) ; i++) { float_part *= 2.0; |