File tree 3 files changed +12
-23
lines changed
3 files changed +12
-23
lines changed Original file line number Diff line number Diff line change 39
39
// Return 1 if float or double arg is neither infinite nor NAN, else 0.
40
40
#define Py_IS_FINITE (X ) isfinite(X)
41
41
42
- /* HUGE_VAL is supposed to expand to a positive double infinity. Python
43
- * uses Py_HUGE_VAL instead because some platforms are broken in this
44
- * respect. We used to embed code in pyport.h to try to worm around that,
45
- * but different platforms are broken in conflicting ways. If you're on
46
- * a platform where HUGE_VAL is defined incorrectly, fiddle your Python
47
- * config to #define Py_HUGE_VAL to something that works on your platform.
42
+ // Py_INFINITY: Value that evaluates to a positive double infinity.
43
+ #ifndef Py_INFINITY
44
+ # define Py_INFINITY ((double)INFINITY)
45
+ #endif
46
+
47
+ /* Py_HUGE_VAL should always be the same as Py_INFINITY. But historically
48
+ * this was not reliable and Python did not require IEEE floats and C99
49
+ * conformity. Prefer Py_INFINITY for new code.
48
50
*/
49
51
#ifndef Py_HUGE_VAL
50
52
# define Py_HUGE_VAL HUGE_VAL
51
53
#endif
52
54
53
- // Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN).
55
+ // Py_NAN: Value that evaluates to a quiet and positive Not-a-Number (NaN).
54
56
#if !defined(Py_NAN )
55
57
# if _Py__has_builtin (__builtin_nan )
56
58
// Built-in implementation of the ISO C99 function nan(): quiet NaN.
Original file line number Diff line number Diff line change @@ -1230,25 +1230,18 @@ cmath_exec(PyObject *mod)
1230
1230
return -1 ;
1231
1231
}
1232
1232
1233
- Py_complex infj = {0.0 , Py_HUGE_VAL };
1233
+ Py_complex infj = {0.0 , Py_INFINITY };
1234
1234
if (PyModule_AddObject (mod , "infj" ,
1235
1235
PyComplex_FromCComplex (infj )) < 0 ) {
1236
1236
return -1 ;
1237
1237
}
1238
- #if _PY_SHORT_FLOAT_REPR == 1
1239
- /*
1240
- * NaN exposure is guarded by having IEEE doubles via _PY_SHORT_FLOAT_REPR.
1241
- * This is probably an overly restrictive guard.
1242
- */
1243
1238
if (PyModule_AddObject (mod , "nan" , PyFloat_FromDouble (Py_NAN )) < 0 ) {
1244
1239
return -1 ;
1245
1240
}
1246
1241
Py_complex nanj = {0.0 , Py_NAN };
1247
- if (PyModule_AddObject (mod , "nanj" ,
1248
- PyComplex_FromCComplex (nanj )) < 0 ) {
1242
+ if (PyModule_AddObject (mod , "nanj" , PyComplex_FromCComplex (nanj )) < 0 ) {
1249
1243
return -1 ;
1250
1244
}
1251
- #endif
1252
1245
1253
1246
/* initialize special value tables */
1254
1247
Original file line number Diff line number Diff line change @@ -3946,18 +3946,12 @@ math_exec(PyObject *module)
3946
3946
if (PyModule_AddObject (module , "tau" , PyFloat_FromDouble (Py_MATH_TAU )) < 0 ) {
3947
3947
return -1 ;
3948
3948
}
3949
- if (PyModule_AddObject (module , "inf" , PyFloat_FromDouble (Py_HUGE_VAL )) < 0 ) {
3949
+ if (PyModule_AddObject (module , "inf" , PyFloat_FromDouble (Py_INFINITY )) < 0 ) {
3950
3950
return -1 ;
3951
3951
}
3952
- #if _PY_SHORT_FLOAT_REPR == 1
3953
- /*
3954
- * NaN exposure is guarded by having IEEE doubles via _PY_SHORT_FLOAT_REPR.
3955
- * This is probably an overly restrictive guard.
3956
- */
3957
3952
if (PyModule_AddObject (module , "nan" , PyFloat_FromDouble (Py_NAN )) < 0 ) {
3958
3953
return -1 ;
3959
3954
}
3960
- #endif
3961
3955
return 0 ;
3962
3956
}
3963
3957
You can’t perform that action at this time.
0 commit comments