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