@@ -383,10 +383,11 @@ static int millis_from_datetime_ms(PyObject* dt, long long* out){
383
383
static PyObject * decode_datetime (PyObject * self , long long millis , const codec_options_t * options ){
384
384
PyObject * naive = NULL ;
385
385
PyObject * replace = NULL ;
386
- PyObject * args = NULL ;
387
- PyObject * kwargs = NULL ;
388
386
PyObject * value = NULL ;
389
387
struct module_state * state = GETSTATE (self );
388
+ if (!state ) {
389
+ goto invalid ;
390
+ }
390
391
if (options -> datetime_conversion == DATETIME_MS ){
391
392
return datetime_ms_from_millis (self , millis );
392
393
}
@@ -414,8 +415,8 @@ static PyObject* decode_datetime(PyObject* self, long long millis, const codec_o
414
415
Py_DECREF (utcoffset );
415
416
return 0 ;
416
417
}
417
- min_millis_offset = (PyDateTime_DELTA_GET_DAYS (utcoffset ) * 86400 +
418
- PyDateTime_DELTA_GET_SECONDS (utcoffset )) * 1000 +
418
+ min_millis_offset = (PyDateTime_DELTA_GET_DAYS (utcoffset ) * ( int64_t ) 86400 +
419
+ PyDateTime_DELTA_GET_SECONDS (utcoffset )) * ( int64_t ) 1000 +
419
420
(PyDateTime_DELTA_GET_MICROSECONDS (utcoffset ) / 1000 );
420
421
}
421
422
Py_DECREF (utcoffset );
@@ -433,8 +434,8 @@ static PyObject* decode_datetime(PyObject* self, long long millis, const codec_o
433
434
Py_DECREF (utcoffset );
434
435
return 0 ;
435
436
}
436
- max_millis_offset = (PyDateTime_DELTA_GET_DAYS (utcoffset ) * 86400 +
437
- PyDateTime_DELTA_GET_SECONDS (utcoffset )) * 1000 +
437
+ max_millis_offset = (PyDateTime_DELTA_GET_DAYS (utcoffset ) * ( int64_t ) 86400 +
438
+ PyDateTime_DELTA_GET_SECONDS (utcoffset )) * ( int64_t ) 1000 +
438
439
(PyDateTime_DELTA_GET_MICROSECONDS (utcoffset ) / 1000 );
439
440
}
440
441
Py_DECREF (utcoffset );
@@ -487,8 +488,6 @@ static PyObject* decode_datetime(PyObject* self, long long millis, const codec_o
487
488
invalid :
488
489
Py_XDECREF (naive );
489
490
Py_XDECREF (replace );
490
- Py_XDECREF (args );
491
- Py_XDECREF (kwargs );
492
491
return value ;
493
492
}
494
493
0 commit comments