@@ -1089,17 +1089,20 @@ math_2(PyObject *const *args, Py_ssize_t nargs,
10891089 }\
10901090 PyDoc_STRVAR(math_##funcname##_doc, docstring);
10911091
1092- FUNC1 (acos , acos , 0 ,
1092+ FUNC1D (acos , acos , 0 ,
10931093 "acos($module, x, /)\n--\n\n"
10941094 "Return the arc cosine (measured in radians) of x.\n\n"
1095- "The result is between 0 and pi." )
1096- FUNC1 (acosh , acosh , 0 ,
1095+ "The result is between 0 and pi." ,
1096+ "expected a number in range from -1 up to 1, got %s" )
1097+ FUNC1D (acosh , acosh , 0 ,
10971098 "acosh($module, x, /)\n--\n\n"
1098- "Return the inverse hyperbolic cosine of x." )
1099- FUNC1 (asin , asin , 0 ,
1099+ "Return the inverse hyperbolic cosine of x." ,
1100+ "expected argument value not less than 1, got %s" )
1101+ FUNC1D (asin , asin , 0 ,
11001102 "asin($module, x, /)\n--\n\n"
11011103 "Return the arc sine (measured in radians) of x.\n\n"
1102- "The result is between -pi/2 and pi/2." )
1104+ "The result is between -pi/2 and pi/2." ,
1105+ "expected a number in range from -1 up to 1, got %s" )
11031106FUNC1 (asinh , asinh , 0 ,
11041107 "asinh($module, x, /)\n--\n\n"
11051108 "Return the inverse hyperbolic sine of x." )
@@ -1161,9 +1164,10 @@ FUNC2(copysign, copysign,
11611164 "Return a float with the magnitude (absolute value) of x but the sign of y.\n\n"
11621165 "On platforms that support signed zeros, copysign(1.0, -0.0)\n"
11631166 "returns -1.0.\n" )
1164- FUNC1 (cos , cos , 0 ,
1167+ FUNC1D (cos , cos , 0 ,
11651168 "cos($module, x, /)\n--\n\n"
1166- "Return the cosine of x (measured in radians)." )
1169+ "Return the cosine of x (measured in radians)." ,
1170+ "expected a finite input, got %s" )
11671171FUNC1 (cosh , cosh , 1 ,
11681172 "cosh($module, x, /)\n--\n\n"
11691173 "Return the hyperbolic cosine of x." )
@@ -1229,32 +1233,36 @@ FUNC1AD(gamma, m_tgamma,
12291233 "gamma($module, x, /)\n--\n\n"
12301234 "Gamma function at x." ,
12311235 "expected a float or nonnegative integer, got %s" )
1232- FUNC1A (lgamma , m_lgamma ,
1236+ FUNC1AD (lgamma , m_lgamma ,
12331237 "lgamma($module, x, /)\n--\n\n"
1234- "Natural logarithm of absolute value of Gamma function at x." )
1235- FUNC1 (log1p , m_log1p , 0 ,
1238+ "Natural logarithm of absolute value of Gamma function at x." ,
1239+ "expected a float or nonnegative integer, got %s" )
1240+ FUNC1D (log1p , m_log1p , 0 ,
12361241 "log1p($module, x, /)\n--\n\n"
12371242 "Return the natural logarithm of 1+x (base e).\n\n"
1238- "The result is computed in a way which is accurate for x near zero." )
1243+ "The result is computed in a way which is accurate for x near zero." ,
1244+ "expected argument value > -1, got %s" )
12391245FUNC2 (remainder , m_remainder ,
12401246 "remainder($module, x, y, /)\n--\n\n"
12411247 "Difference between x and the closest integer multiple of y.\n\n"
12421248 "Return x - n*y where n*y is the closest integer multiple of y.\n"
12431249 "In the case where x is exactly halfway between two multiples of\n"
12441250 "y, the nearest even value of n is used. The result is always exact." )
1245- FUNC1 (sin , sin , 0 ,
1251+ FUNC1D (sin , sin , 0 ,
12461252 "sin($module, x, /)\n--\n\n"
1247- "Return the sine of x (measured in radians)." )
1253+ "Return the sine of x (measured in radians)." ,
1254+ "expected a finite input, got %s" )
12481255FUNC1 (sinh , sinh , 1 ,
12491256 "sinh($module, x, /)\n--\n\n"
12501257 "Return the hyperbolic sine of x." )
12511258FUNC1D (sqrt , sqrt , 0 ,
12521259 "sqrt($module, x, /)\n--\n\n"
12531260 "Return the square root of x." ,
12541261 "expected a nonnegative input, got %s" )
1255- FUNC1 (tan , tan , 0 ,
1262+ FUNC1D (tan , tan , 0 ,
12561263 "tan($module, x, /)\n--\n\n"
1257- "Return the tangent of x (measured in radians)." )
1264+ "Return the tangent of x (measured in radians)." ,
1265+ "expected a finite input, got %s" )
12581266FUNC1 (tanh , tanh , 0 ,
12591267 "tanh($module, x, /)\n--\n\n"
12601268 "Return the hyperbolic tangent of x." )
@@ -2232,8 +2240,10 @@ loghelper(PyObject* arg, double (*func)(double))
22322240
22332241 /* Negative or zero inputs give a ValueError. */
22342242 if (!_PyLong_IsPositive ((PyLongObject * )arg )) {
2235- PyErr_Format (PyExc_ValueError ,
2236- "expected a positive input, got %S" , arg );
2243+ /* The input can be an arbitrary large integer, so we
2244+ don't include it's value in the error message. */
2245+ PyErr_SetString (PyExc_ValueError ,
2246+ "expected a positive input" );
22372247 return NULL ;
22382248 }
22392249
0 commit comments