@@ -1023,6 +1023,19 @@ PyDoc_STRVAR(cmath_rect_doc,
10231023"rect(r, phi) -> z: complex\n\n\
10241024Convert from polar coordinates to rectangular coordinates." );
10251025
1026+ static PyObject *
1027+ cmath_isfinite (PyObject * self , PyObject * args )
1028+ {
1029+ Py_complex z ;
1030+ if (!PyArg_ParseTuple (args , "D:isfinite" , & z ))
1031+ return NULL ;
1032+ return PyBool_FromLong (Py_IS_FINITE (z .real ) && Py_IS_FINITE (z .imag ));
1033+ }
1034+
1035+ PyDoc_STRVAR (cmath_isfinite_doc ,
1036+ "isfinite(z) -> bool\n\
1037+ Return True if both the real and imaginary parts of z are finite, else False." );
1038+
10261039static PyObject *
10271040cmath_isnan (PyObject * self , PyObject * args )
10281041{
@@ -1065,6 +1078,7 @@ static PyMethodDef cmath_methods[] = {
10651078 {"cos" , cmath_cos , METH_VARARGS , c_cos_doc },
10661079 {"cosh" , cmath_cosh , METH_VARARGS , c_cosh_doc },
10671080 {"exp" , cmath_exp , METH_VARARGS , c_exp_doc },
1081+ {"isfinite" , cmath_isfinite , METH_VARARGS , cmath_isfinite_doc },
10681082 {"isinf" , cmath_isinf , METH_VARARGS , cmath_isinf_doc },
10691083 {"isnan" , cmath_isnan , METH_VARARGS , cmath_isnan_doc },
10701084 {"log" , cmath_log , METH_VARARGS , cmath_log_doc },
0 commit comments