Skip to content

Commit be143ec

Browse files
authored
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 735ae8d), so stop using them.
1 parent 01b1cc1 commit be143ec

File tree

9 files changed

+20
-101
lines changed

9 files changed

+20
-101
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The ``PyFPE_START_PROTECT()`` and ``PyFPE_END_PROTECT()`` macros are empty:
2+
they have been doing nothing for the last year, so stop using them.

Modules/_tkinter.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,11 +2166,9 @@ _tkinter_tkapp_exprdouble_impl(TkappObject *self, const char *s)
21662166

21672167
CHECK_STRING_LENGTH(s);
21682168
CHECK_TCL_APPARTMENT;
2169-
PyFPE_START_PROTECT("Tkapp_ExprDouble", return 0)
21702169
ENTER_TCL
21712170
retval = Tcl_ExprDouble(Tkapp_Interp(self), s, &v);
21722171
ENTER_OVERLAP
2173-
PyFPE_END_PROTECT(retval)
21742172
if (retval == TCL_ERROR)
21752173
res = Tkinter_Error(self);
21762174
else

Modules/clinic/cmathmodule.c.h

Lines changed: 16 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/cmathmodule.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module cmath
1717
/*[python input]
1818
class Py_complex_protected_converter(Py_complex_converter):
1919
def modify(self):
20-
return 'errno = 0; PyFPE_START_PROTECT("complex function", goto exit);'
20+
return 'errno = 0;'
2121
2222
2323
class Py_complex_protected_return_converter(CReturnConverter):
@@ -26,7 +26,6 @@ class Py_complex_protected_return_converter(CReturnConverter):
2626
def render(self, function, data):
2727
self.declare(data)
2828
data.return_conversion.append("""
29-
PyFPE_END_PROTECT(_return_value);
3029
if (errno == EDOM) {
3130
PyErr_SetString(PyExc_ValueError, "math domain error");
3231
goto exit;
@@ -40,7 +39,7 @@ else {
4039
}
4140
""".strip())
4241
[python start generated code]*/
43-
/*[python end generated code: output=da39a3ee5e6b4b0d input=345daa075b1028e7]*/
42+
/*[python end generated code: output=da39a3ee5e6b4b0d input=8b27adb674c08321]*/
4443

4544
#if (FLT_RADIX != 2 && FLT_RADIX != 16)
4645
#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)
960959
Py_complex y;
961960

962961
errno = 0;
963-
PyFPE_START_PROTECT("complex function", return 0)
964962
x = c_log(x);
965963
if (y_obj != NULL) {
966964
y = PyComplex_AsCComplex(y_obj);
@@ -970,7 +968,6 @@ cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj)
970968
y = c_log(y);
971969
x = _Py_c_quot(x, y);
972970
}
973-
PyFPE_END_PROTECT(x)
974971
if (errno != 0)
975972
return math_error();
976973
return PyComplex_FromCComplex(x);
@@ -1008,9 +1005,7 @@ cmath_phase_impl(PyObject *module, Py_complex z)
10081005
double phi;
10091006

10101007
errno = 0;
1011-
PyFPE_START_PROTECT("arg function", return 0)
10121008
phi = c_atan2(z);
1013-
PyFPE_END_PROTECT(phi)
10141009
if (errno != 0)
10151010
return math_error();
10161011
else
@@ -1035,10 +1030,8 @@ cmath_polar_impl(PyObject *module, Py_complex z)
10351030
double r, phi;
10361031

10371032
errno = 0;
1038-
PyFPE_START_PROTECT("polar function", return 0)
10391033
phi = c_atan2(z); /* should not cause any exception */
10401034
r = _Py_c_abs(z); /* sets errno to ERANGE on overflow */
1041-
PyFPE_END_PROTECT(r)
10421035
if (errno != 0)
10431036
return math_error();
10441037
else
@@ -1074,7 +1067,6 @@ cmath_rect_impl(PyObject *module, double r, double phi)
10741067
{
10751068
Py_complex z;
10761069
errno = 0;
1077-
PyFPE_START_PROTECT("rect function", return 0)
10781070

10791071
/* deal with special values */
10801072
if (!Py_IS_FINITE(r) || !Py_IS_FINITE(phi)) {
@@ -1116,7 +1108,6 @@ cmath_rect_impl(PyObject *module, double r, double phi)
11161108
errno = 0;
11171109
}
11181110

1119-
PyFPE_END_PROTECT(z)
11201111
if (errno != 0)
11211112
return math_error();
11221113
else

Modules/mathmodule.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -936,9 +936,7 @@ math_1_to_whatever(PyObject *arg, double (*func) (double),
936936
if (x == -1.0 && PyErr_Occurred())
937937
return NULL;
938938
errno = 0;
939-
PyFPE_START_PROTECT("in math_1", return 0);
940939
r = (*func)(x);
941-
PyFPE_END_PROTECT(r);
942940
if (Py_IS_NAN(r) && !Py_IS_NAN(x)) {
943941
PyErr_SetString(PyExc_ValueError,
944942
"math domain error"); /* invalid arg */
@@ -972,9 +970,7 @@ math_1a(PyObject *arg, double (*func) (double))
972970
if (x == -1.0 && PyErr_Occurred())
973971
return NULL;
974972
errno = 0;
975-
PyFPE_START_PROTECT("in math_1a", return 0);
976973
r = (*func)(x);
977-
PyFPE_END_PROTECT(r);
978974
if (errno && is_error(r))
979975
return NULL;
980976
return PyFloat_FromDouble(r);
@@ -1025,9 +1021,7 @@ math_2(PyObject *const *args, Py_ssize_t nargs,
10251021
if ((x == -1.0 || y == -1.0) && PyErr_Occurred())
10261022
return NULL;
10271023
errno = 0;
1028-
PyFPE_START_PROTECT("in math_2", return 0);
10291024
r = (*func)(x, y);
1030-
PyFPE_END_PROTECT(r);
10311025
if (Py_IS_NAN(r)) {
10321026
if (!Py_IS_NAN(x) && !Py_IS_NAN(y))
10331027
errno = EDOM;
@@ -1340,8 +1334,6 @@ math_fsum(PyObject *module, PyObject *seq)
13401334
if (iter == NULL)
13411335
return NULL;
13421336

1343-
PyFPE_START_PROTECT("fsum", Py_DECREF(iter); return NULL)
1344-
13451337
for(;;) { /* for x in iterable */
13461338
assert(0 <= n && n <= m);
13471339
assert((m == NUM_PARTIALS && p == ps) ||
@@ -1436,7 +1428,6 @@ math_fsum(PyObject *module, PyObject *seq)
14361428
sum = PyFloat_FromDouble(hi);
14371429

14381430
_fsum_error:
1439-
PyFPE_END_PROTECT(hi)
14401431
Py_DECREF(iter);
14411432
if (p != ps)
14421433
PyMem_Free(p);
@@ -2111,9 +2102,7 @@ math_frexp_impl(PyObject *module, double x)
21112102
i = 0;
21122103
}
21132104
else {
2114-
PyFPE_START_PROTECT("in math_frexp", return 0);
21152105
x = frexp(x, &i);
2116-
PyFPE_END_PROTECT(x);
21172106
}
21182107
return Py_BuildValue("(di)", x, i);
21192108
}
@@ -2168,9 +2157,7 @@ math_ldexp_impl(PyObject *module, double x, PyObject *i)
21682157
errno = 0;
21692158
} else {
21702159
errno = 0;
2171-
PyFPE_START_PROTECT("in math_ldexp", return 0);
21722160
r = ldexp(x, (int)exp);
2173-
PyFPE_END_PROTECT(r);
21742161
if (Py_IS_INFINITY(r))
21752162
errno = ERANGE;
21762163
}
@@ -2207,9 +2194,7 @@ math_modf_impl(PyObject *module, double x)
22072194
}
22082195

22092196
errno = 0;
2210-
PyFPE_START_PROTECT("in math_modf", return 0);
22112197
x = modf(x, &y);
2212-
PyFPE_END_PROTECT(x);
22132198
return Py_BuildValue("(dd)", x, y);
22142199
}
22152200

@@ -2356,9 +2341,7 @@ math_fmod_impl(PyObject *module, double x, double y)
23562341
if (Py_IS_INFINITY(y) && Py_IS_FINITE(x))
23572342
return PyFloat_FromDouble(x);
23582343
errno = 0;
2359-
PyFPE_START_PROTECT("in math_fmod", return 0);
23602344
r = fmod(x, y);
2361-
PyFPE_END_PROTECT(r);
23622345
if (Py_IS_NAN(r)) {
23632346
if (!Py_IS_NAN(x) && !Py_IS_NAN(y))
23642347
errno = EDOM;
@@ -2646,9 +2629,7 @@ math_pow_impl(PyObject *module, double x, double y)
26462629
else {
26472630
/* let libm handle finite**finite */
26482631
errno = 0;
2649-
PyFPE_START_PROTECT("in math_pow", return 0);
26502632
r = pow(x, y);
2651-
PyFPE_END_PROTECT(r);
26522633
/* a NaN result should arise only from (-ve)**(finite
26532634
non-integer); in this case we want to raise ValueError. */
26542635
if (!Py_IS_FINITE(r)) {

0 commit comments

Comments
 (0)