@@ -6878,24 +6878,49 @@ _datetime_exec(PyObject *module)
6878
6878
assert (DI100Y == days_before_year (100 + 1 ));
6879
6879
6880
6880
us_per_ms = PyLong_FromLong (1000 );
6881
+ if (us_per_ms == NULL ) {
6882
+ goto error ;
6883
+ }
6881
6884
us_per_second = PyLong_FromLong (1000000 );
6885
+ if (us_per_second == NULL ) {
6886
+ goto error ;
6887
+ }
6882
6888
us_per_minute = PyLong_FromLong (60000000 );
6889
+ if (us_per_minute == NULL ) {
6890
+ goto error ;
6891
+ }
6883
6892
seconds_per_day = PyLong_FromLong (24 * 3600 );
6884
- if (us_per_ms == NULL || us_per_second == NULL ||
6885
- us_per_minute == NULL || seconds_per_day == NULL ) {
6886
- return -1 ;
6893
+ if (seconds_per_day == NULL ) {
6894
+ goto error ;
6887
6895
}
6888
6896
6889
6897
/* The rest are too big for 32-bit ints, but even
6890
6898
* us_per_week fits in 40 bits, so doubles should be exact.
6891
6899
*/
6892
6900
us_per_hour = PyLong_FromDouble (3600000000.0 );
6901
+ if (us_per_hour == NULL ) {
6902
+ goto error ;
6903
+ }
6893
6904
us_per_day = PyLong_FromDouble (86400000000.0 );
6905
+ if (us_per_day == NULL ) {
6906
+ goto error ;
6907
+ }
6894
6908
us_per_week = PyLong_FromDouble (604800000000.0 );
6895
- if (us_per_hour == NULL || us_per_day == NULL || us_per_week == NULL ) {
6896
- return -1 ;
6909
+ if (us_per_week == NULL ) {
6910
+ goto error ;
6897
6911
}
6912
+
6898
6913
return 0 ;
6914
+
6915
+ error :
6916
+ Py_XDECREF (us_per_ms );
6917
+ Py_XDECREF (us_per_second );
6918
+ Py_XDECREF (us_per_minute );
6919
+ Py_XDECREF (us_per_hour );
6920
+ Py_XDECREF (us_per_day );
6921
+ Py_XDECREF (us_per_week );
6922
+ Py_XDECREF (seconds_per_day );
6923
+ return -1 ;
6899
6924
}
6900
6925
6901
6926
static struct PyModuleDef datetimemodule = {
0 commit comments