@@ -117,7 +117,7 @@ enum special_types {
117117static enum special_types
118118special_type (double d )
119119{
120- if (Py_IS_FINITE (d )) {
120+ if (isfinite (d )) {
121121 if (d != 0 ) {
122122 if (copysign (1. , d ) == 1. )
123123 return ST_POS ;
@@ -131,19 +131,19 @@ special_type(double d)
131131 return ST_NZERO ;
132132 }
133133 }
134- if (Py_IS_NAN (d ))
134+ if (isnan (d ))
135135 return ST_NAN ;
136136 if (copysign (1. , d ) == 1. )
137137 return ST_PINF ;
138138 else
139139 return ST_NINF ;
140140}
141141
142- #define SPECIAL_VALUE (z , table ) \
143- if (!Py_IS_FINITE ((z).real) || !Py_IS_FINITE ((z).imag)) { \
144- errno = 0; \
145- return table[special_type((z).real)] \
146- [special_type((z).imag)]; \
142+ #define SPECIAL_VALUE (z , table ) \
143+ if (!isfinite ((z).real) || !isfinite ((z).imag)) { \
144+ errno = 0; \
145+ return table[special_type((z).real)] \
146+ [special_type((z).imag)]; \
147147 }
148148
149149#define P Py_MATH_PI
@@ -329,10 +329,10 @@ cmath_atan_impl(PyObject *module, Py_complex z)
329329static double
330330c_atan2 (Py_complex z )
331331{
332- if (Py_IS_NAN (z .real ) || Py_IS_NAN (z .imag ))
332+ if (isnan (z .real ) || isnan (z .imag ))
333333 return Py_NAN ;
334- if (Py_IS_INFINITY (z .imag )) {
335- if (Py_IS_INFINITY (z .real )) {
334+ if (isinf (z .imag )) {
335+ if (isinf (z .real )) {
336336 if (copysign (1. , z .real ) == 1. )
337337 /* atan2(+-inf, +inf) == +-pi/4 */
338338 return copysign (0.25 * Py_MATH_PI , z .imag );
@@ -343,7 +343,7 @@ c_atan2(Py_complex z)
343343 /* atan2(+-inf, x) == +-pi/2 for finite x */
344344 return copysign (0.5 * Py_MATH_PI , z .imag );
345345 }
346- if (Py_IS_INFINITY (z .real ) || z .imag == 0. ) {
346+ if (isinf (z .real ) || z .imag == 0. ) {
347347 if (copysign (1. , z .real ) == 1. )
348348 /* atan2(+-y, +inf) = atan2(+-0, +x) = +-0. */
349349 return copysign (0. , z .imag );
@@ -448,8 +448,8 @@ cmath_cosh_impl(PyObject *module, Py_complex z)
448448 double x_minus_one ;
449449
450450 /* special treatment for cosh(+/-inf + iy) if y is not a NaN */
451- if (!Py_IS_FINITE (z .real ) || !Py_IS_FINITE (z .imag )) {
452- if (Py_IS_INFINITY (z .real ) && Py_IS_FINITE (z .imag ) &&
451+ if (!isfinite (z .real ) || !isfinite (z .imag )) {
452+ if (isinf (z .real ) && isfinite (z .imag ) &&
453453 (z .imag != 0. )) {
454454 if (z .real > 0 ) {
455455 r .real = copysign (INF , cos (z .imag ));
@@ -466,7 +466,7 @@ cmath_cosh_impl(PyObject *module, Py_complex z)
466466 }
467467 /* need to set errno = EDOM if y is +/- infinity and x is not
468468 a NaN */
469- if (Py_IS_INFINITY (z .imag ) && !Py_IS_NAN (z .real ))
469+ if (isinf (z .imag ) && !isnan (z .real ))
470470 errno = EDOM ;
471471 else
472472 errno = 0 ;
@@ -484,7 +484,7 @@ cmath_cosh_impl(PyObject *module, Py_complex z)
484484 r .imag = sin (z .imag ) * sinh (z .real );
485485 }
486486 /* detect overflow, and set errno accordingly */
487- if (Py_IS_INFINITY (r .real ) || Py_IS_INFINITY (r .imag ))
487+ if (isinf (r .real ) || isinf (r .imag ))
488488 errno = ERANGE ;
489489 else
490490 errno = 0 ;
@@ -509,8 +509,8 @@ cmath_exp_impl(PyObject *module, Py_complex z)
509509 Py_complex r ;
510510 double l ;
511511
512- if (!Py_IS_FINITE (z .real ) || !Py_IS_FINITE (z .imag )) {
513- if (Py_IS_INFINITY (z .real ) && Py_IS_FINITE (z .imag )
512+ if (!isfinite (z .real ) || !isfinite (z .imag )) {
513+ if (isinf (z .real ) && isfinite (z .imag )
514514 && (z .imag != 0. )) {
515515 if (z .real > 0 ) {
516516 r .real = copysign (INF , cos (z .imag ));
@@ -527,9 +527,9 @@ cmath_exp_impl(PyObject *module, Py_complex z)
527527 }
528528 /* need to set errno = EDOM if y is +/- infinity and x is not
529529 a NaN and not -infinity */
530- if (Py_IS_INFINITY (z .imag ) &&
531- (Py_IS_FINITE (z .real ) ||
532- (Py_IS_INFINITY (z .real ) && z .real > 0 )))
530+ if (isinf (z .imag ) &&
531+ (isfinite (z .real ) ||
532+ (isinf (z .real ) && z .real > 0 )))
533533 errno = EDOM ;
534534 else
535535 errno = 0 ;
@@ -546,7 +546,7 @@ cmath_exp_impl(PyObject *module, Py_complex z)
546546 r .imag = l * sin (z .imag );
547547 }
548548 /* detect overflow, and set errno accordingly */
549- if (Py_IS_INFINITY (r .real ) || Py_IS_INFINITY (r .imag ))
549+ if (isinf (r .real ) || isinf (r .imag ))
550550 errno = ERANGE ;
551551 else
552552 errno = 0 ;
@@ -686,8 +686,8 @@ cmath_sinh_impl(PyObject *module, Py_complex z)
686686
687687 /* special treatment for sinh(+/-inf + iy) if y is finite and
688688 nonzero */
689- if (!Py_IS_FINITE (z .real ) || !Py_IS_FINITE (z .imag )) {
690- if (Py_IS_INFINITY (z .real ) && Py_IS_FINITE (z .imag )
689+ if (!isfinite (z .real ) || !isfinite (z .imag )) {
690+ if (isinf (z .real ) && isfinite (z .imag )
691691 && (z .imag != 0. )) {
692692 if (z .real > 0 ) {
693693 r .real = copysign (INF , cos (z .imag ));
@@ -704,7 +704,7 @@ cmath_sinh_impl(PyObject *module, Py_complex z)
704704 }
705705 /* need to set errno = EDOM if y is +/- infinity and x is not
706706 a NaN */
707- if (Py_IS_INFINITY (z .imag ) && !Py_IS_NAN (z .real ))
707+ if (isinf (z .imag ) && !isnan (z .real ))
708708 errno = EDOM ;
709709 else
710710 errno = 0 ;
@@ -720,7 +720,7 @@ cmath_sinh_impl(PyObject *module, Py_complex z)
720720 r .imag = sin (z .imag ) * cosh (z .real );
721721 }
722722 /* detect overflow, and set errno accordingly */
723- if (Py_IS_INFINITY (r .real ) || Py_IS_INFINITY (r .imag ))
723+ if (isinf (r .real ) || isinf (r .imag ))
724724 errno = ERANGE ;
725725 else
726726 errno = 0 ;
@@ -856,8 +856,8 @@ cmath_tanh_impl(PyObject *module, Py_complex z)
856856
857857 /* special treatment for tanh(+/-inf + iy) if y is finite and
858858 nonzero */
859- if (!Py_IS_FINITE (z .real ) || !Py_IS_FINITE (z .imag )) {
860- if (Py_IS_INFINITY (z .real ) && Py_IS_FINITE (z .imag )
859+ if (!isfinite (z .real ) || !isfinite (z .imag )) {
860+ if (isinf (z .real ) && isfinite (z .imag )
861861 && (z .imag != 0. )) {
862862 if (z .real > 0 ) {
863863 r .real = 1.0 ;
@@ -876,7 +876,7 @@ cmath_tanh_impl(PyObject *module, Py_complex z)
876876 }
877877 /* need to set errno = EDOM if z.imag is +/-infinity and
878878 z.real is finite */
879- if (Py_IS_INFINITY (z .imag ) && Py_IS_FINITE (z .real ))
879+ if (isinf (z .imag ) && isfinite (z .real ))
880880 errno = EDOM ;
881881 else
882882 errno = 0 ;
@@ -1030,11 +1030,11 @@ cmath_rect_impl(PyObject *module, double r, double phi)
10301030 errno = 0 ;
10311031
10321032 /* deal with special values */
1033- if (!Py_IS_FINITE (r ) || !Py_IS_FINITE (phi )) {
1033+ if (!isfinite (r ) || !isfinite (phi )) {
10341034 /* if r is +/-infinity and phi is finite but nonzero then
10351035 result is (+-INF +-INF i), but we need to compute cos(phi)
10361036 and sin(phi) to figure out the signs. */
1037- if (Py_IS_INFINITY (r ) && (Py_IS_FINITE (phi )
1037+ if (isinf (r ) && (isfinite (phi )
10381038 && (phi != 0. ))) {
10391039 if (r > 0 ) {
10401040 z .real = copysign (INF , cos (phi ));
@@ -1051,7 +1051,7 @@ cmath_rect_impl(PyObject *module, double r, double phi)
10511051 }
10521052 /* need to set errno = EDOM if r is a nonzero number and phi
10531053 is infinite */
1054- if (r != 0. && !Py_IS_NAN (r ) && Py_IS_INFINITY (phi ))
1054+ if (r != 0. && !isnan (r ) && isinf (phi ))
10551055 errno = EDOM ;
10561056 else
10571057 errno = 0 ;
@@ -1085,7 +1085,7 @@ static PyObject *
10851085cmath_isfinite_impl (PyObject * module , Py_complex z )
10861086/*[clinic end generated code: output=ac76611e2c774a36 input=848e7ee701895815]*/
10871087{
1088- return PyBool_FromLong (Py_IS_FINITE (z .real ) && Py_IS_FINITE (z .imag ));
1088+ return PyBool_FromLong (isfinite (z .real ) && isfinite (z .imag ));
10891089}
10901090
10911091/*[clinic input]
@@ -1098,7 +1098,7 @@ static PyObject *
10981098cmath_isnan_impl (PyObject * module , Py_complex z )
10991099/*[clinic end generated code: output=e7abf6e0b28beab7 input=71799f5d284c9baf]*/
11001100{
1101- return PyBool_FromLong (Py_IS_NAN (z .real ) || Py_IS_NAN (z .imag ));
1101+ return PyBool_FromLong (isnan (z .real ) || isnan (z .imag ));
11021102}
11031103
11041104/*[clinic input]
@@ -1111,8 +1111,7 @@ static PyObject *
11111111cmath_isinf_impl (PyObject * module , Py_complex z )
11121112/*[clinic end generated code: output=502a75a79c773469 input=363df155c7181329]*/
11131113{
1114- return PyBool_FromLong (Py_IS_INFINITY (z .real ) ||
1115- Py_IS_INFINITY (z .imag ));
1114+ return PyBool_FromLong (isinf (z .real ) || isinf (z .imag ));
11161115}
11171116
11181117/*[clinic input]
@@ -1167,8 +1166,7 @@ cmath_isclose_impl(PyObject *module, Py_complex a, Py_complex b,
11671166 above.
11681167 */
11691168
1170- if (Py_IS_INFINITY (a .real ) || Py_IS_INFINITY (a .imag ) ||
1171- Py_IS_INFINITY (b .real ) || Py_IS_INFINITY (b .imag )) {
1169+ if (isinf (a .real ) || isinf (a .imag ) || isinf (b .real ) || isinf (b .imag )) {
11721170 return 0 ;
11731171 }
11741172
0 commit comments