@@ -1537,6 +1537,7 @@ delta_to_microseconds(PyDateTime_Delta *self)
15371537 if (x2 == NULL )
15381538 goto Done ;
15391539 result = PyNumber_Add (x1 , x2 );
1540+ assert (result == NULL || PyInt_CheckExact (result ) || PyLong_CheckExact (result ));
15401541
15411542Done :
15421543 Py_XDECREF (x1 );
@@ -1559,6 +1560,7 @@ microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type)
15591560 PyObject * num = NULL ;
15601561 PyObject * result = NULL ;
15611562
1563+ assert (PyInt_CheckExact (pyus ) || PyLong_CheckExact (pyus ));
15621564 tuple = PyNumber_Divmod (pyus , us_per_second );
15631565 if (tuple == NULL )
15641566 goto Done ;
@@ -1851,11 +1853,13 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
18511853 assert (num != NULL );
18521854
18531855 if (PyInt_Check (num ) || PyLong_Check (num )) {
1854- prod = PyNumber_Multiply (num , factor );
1856+ prod = PyNumber_Multiply (factor , num );
18551857 if (prod == NULL )
18561858 return NULL ;
1859+ assert (PyInt_CheckExact (prod ) || PyLong_CheckExact (prod ));
18571860 sum = PyNumber_Add (sofar , prod );
18581861 Py_DECREF (prod );
1862+ assert (sum == NULL || PyInt_CheckExact (sum ) || PyLong_CheckExact (sum ));
18591863 return sum ;
18601864 }
18611865
@@ -1898,7 +1902,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
18981902 * fractional part requires float arithmetic, and may
18991903 * lose a little info.
19001904 */
1901- assert (PyInt_Check (factor ) || PyLong_Check (factor ));
1905+ assert (PyInt_CheckExact (factor ) || PyLong_CheckExact (factor ));
19021906 if (PyInt_Check (factor ))
19031907 dnum = (double )PyInt_AsLong (factor );
19041908 else
@@ -1916,6 +1920,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
19161920 Py_DECREF (sum );
19171921 Py_DECREF (x );
19181922 * leftover += fracpart ;
1923+ assert (y == NULL || PyInt_CheckExact (y ) || PyLong_CheckExact (y ));
19191924 return y ;
19201925 }
19211926
0 commit comments