@@ -2115,6 +2115,9 @@ delta_to_microseconds(PyDateTime_Delta *self)
21152115
21162116 PyObject * current_mod = NULL ;
21172117 datetime_state * st = GET_CURRENT_STATE (current_mod );
2118+ if (st == NULL ) {
2119+ return NULL ;
2120+ }
21182121
21192122 x1 = PyLong_FromLong (GET_TD_DAYS (self ));
21202123 if (x1 == NULL )
@@ -2194,6 +2197,9 @@ microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type)
21942197
21952198 PyObject * current_mod = NULL ;
21962199 datetime_state * st = GET_CURRENT_STATE (current_mod );
2200+ if (st == NULL ) {
2201+ return NULL ;
2202+ }
21972203
21982204 tuple = checked_divmod (pyus , CONST_US_PER_SECOND (st ));
21992205 if (tuple == NULL ) {
@@ -2779,6 +2785,9 @@ delta_new(PyTypeObject *type, PyObject *args, PyObject *kw)
27792785
27802786 PyObject * current_mod = NULL ;
27812787 datetime_state * st = GET_CURRENT_STATE (current_mod );
2788+ if (st == NULL ) {
2789+ return NULL ;
2790+ }
27822791
27832792 /* Argument objects. */
27842793 PyObject * day = NULL ;
@@ -2998,6 +3007,10 @@ delta_total_seconds(PyObject *op, PyObject *Py_UNUSED(dummy))
29983007
29993008 PyObject * current_mod = NULL ;
30003009 datetime_state * st = GET_CURRENT_STATE (current_mod );
3010+ if (st == NULL ) {
3011+ Py_DECREF (total_microseconds );
3012+ return NULL ;
3013+ }
30013014
30023015 total_seconds = PyNumber_TrueDivide (total_microseconds , CONST_US_PER_SECOND (st ));
30033016
@@ -3781,6 +3794,9 @@ date_isocalendar(PyObject *self, PyObject *Py_UNUSED(dummy))
37813794
37823795 PyObject * current_mod = NULL ;
37833796 datetime_state * st = GET_CURRENT_STATE (current_mod );
3797+ if (st == NULL ) {
3798+ return NULL ;
3799+ }
37843800
37853801 PyObject * v = iso_calendar_date_new_impl (ISOCALENDAR_DATE_TYPE (st ),
37863802 year , week + 1 , day + 1 );
@@ -6616,6 +6632,9 @@ local_timezone(PyDateTime_DateTime *utc_time)
66166632
66176633 PyObject * current_mod = NULL ;
66186634 datetime_state * st = GET_CURRENT_STATE (current_mod );
6635+ if (st == NULL ) {
6636+ return NULL ;
6637+ }
66196638
66206639 delta = datetime_subtract ((PyObject * )utc_time , CONST_EPOCH (st ));
66216640 RELEASE_CURRENT_STATE (st , current_mod );
@@ -6860,6 +6879,9 @@ datetime_timestamp(PyObject *op, PyObject *Py_UNUSED(dummy))
68606879 if (HASTZINFO (self ) && self -> tzinfo != Py_None ) {
68616880 PyObject * current_mod = NULL ;
68626881 datetime_state * st = GET_CURRENT_STATE (current_mod );
6882+ if (st == NULL ) {
6883+ return NULL ;
6884+ }
68636885
68646886 PyObject * delta ;
68656887 delta = datetime_subtract (op , CONST_EPOCH (st ));
0 commit comments