@@ -462,8 +462,8 @@ maybe_as_integer_ratio(PyObject *number, PyObject **ratio)
462462{
463463 * ratio = NULL ;
464464 if (PyType_Check (number )) {
465- PyErr_SetString (PyExc_TypeError ,
466- "required a number, not type" );
465+ PyErr_Format (PyExc_TypeError ,
466+ "must be real number, not %T" , number );
467467 return -1 ;
468468 }
469469 PyObject * meth ;
@@ -960,8 +960,8 @@ pytime_from_object(PyTime_t *tp, PyObject *obj, _PyTime_round_t round,
960960 Py_DECREF (ratio );
961961 return -1 ;
962962 }
963- PyTime_t ns ;
964- if (PyLong_AsInt64 (PyTuple_GET_ITEM (divmod , 0 ), & ns ) < 0 ) {
963+ PyTime_t units ;
964+ if (PyLong_AsInt64 (PyTuple_GET_ITEM (divmod , 0 ), & units ) < 0 ) {
965965 Py_DECREF (divmod );
966966 Py_DECREF (ratio );
967967 if (PyErr_ExceptionMatches (PyExc_OverflowError )) {
@@ -972,7 +972,7 @@ pytime_from_object(PyTime_t *tp, PyObject *obj, _PyTime_round_t round,
972972 if (round == _PyTime_ROUND_UP ) {
973973 /* The remainder is non-negative, so the direction of rounding
974974 depends on the sign of the whole number. */
975- round = ns < 0 ? _PyTime_ROUND_FLOOR : _PyTime_ROUND_CEILING ;
975+ round = units < 0 ? _PyTime_ROUND_FLOOR : _PyTime_ROUND_CEILING ;
976976 }
977977 PyObject * fracobj = multiply_divide_and_round (
978978 unit_to_ns , PyTuple_GET_ITEM (divmod , 1 ),
@@ -987,16 +987,18 @@ pytime_from_object(PyTime_t *tp, PyObject *obj, _PyTime_round_t round,
987987 if (frac == -1 && PyErr_Occurred ()) {
988988 return -1 ;
989989 }
990- if (ns < 0 && frac > 0 ) {
990+ if (units < 0 && frac > 0 ) {
991991 /* Avoid a spurious overflow near PyTime_MIN. */
992- ns += 1 ;
992+ units += 1 ;
993993 frac -= unit_to_ns ;
994994 }
995- if (pytime_mul (& ns , unit_to_ns ) < 0 || pytime_add (& ns , frac ) < 0 ) {
995+ if (pytime_mul (& units , unit_to_ns ) < 0
996+ || pytime_add (& units , frac ) < 0 )
997+ {
996998 pytime_overflow ();
997999 return -1 ;
9981000 }
999- * tp = ns ;
1001+ * tp = units ;
10001002 return 0 ;
10011003 }
10021004}
0 commit comments