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