@@ -53,7 +53,6 @@ typedef struct {
5353 /* The interned Unix epoch datetime instance */
5454 PyObject * epoch ;
5555
56- PyObject * time_time ;
5756 PyObject * time_struct_time ;
5857 PyObject * time_strftime ;
5958} datetime_state ;
@@ -2068,27 +2067,6 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
20682067 * from C. Perhaps they should be.
20692068 */
20702069
2071- /* Call time.time() and return its result (a Python float). */
2072- static PyObject *
2073- time_time (void )
2074- {
2075- PyObject * current_mod = NULL ;
2076- datetime_state * st = GET_CURRENT_STATE (current_mod );
2077- if (st == NULL ) {
2078- return NULL ;
2079- }
2080- if (st -> time_time == NULL ) {
2081- st -> time_time = PyImport_ImportModuleAttrString ("time" , "time" );
2082- if (st -> time_time == NULL ) {
2083- RELEASE_CURRENT_STATE (st , current_mod );
2084- return NULL ;
2085- }
2086- }
2087- PyObject * result = PyObject_CallNoArgs (st -> time_time );
2088- RELEASE_CURRENT_STATE (st , current_mod );
2089- return result ;
2090- }
2091-
20922070/* Build a time.struct_time. The weekday and day number are automatically
20932071 * computed from the y,m,d args.
20942072 */
@@ -3337,14 +3315,18 @@ datetime_date_today_impl(PyTypeObject *type)
33373315 type );
33383316 }
33393317
3340- PyObject * time = time_time () ;
3341- if (time == NULL ) {
3318+ PyTime_t ts ;
3319+ if (PyTime_Time ( & ts ) < 0 ) {
33423320 return NULL ;
33433321 }
33443322
33453323 /* Note well: since today() is a class method, it may not call
33463324 * date.fromtimestamp, e.g., it may call datetime.fromtimestamp.
33473325 */
3326+ PyObject * time = PyFloat_FromDouble (PyTime_AsSecondsDouble (ts ));
3327+ if (time == NULL ) {
3328+ return NULL ;
3329+ }
33483330 PyObject * result = PyObject_CallMethodOneArg ((PyObject * )type , & _Py_ID (fromtimestamp ), time );
33493331 Py_DECREF (time );
33503332 return result ;
@@ -7440,7 +7422,6 @@ init_state(datetime_state *st, PyObject *module, PyObject *old_module)
74407422 .us_per_week = Py_NewRef (st_old -> us_per_week ),
74417423 .seconds_per_day = Py_NewRef (st_old -> seconds_per_day ),
74427424 .epoch = Py_NewRef (st_old -> epoch ),
7443- .time_time = Py_XNewRef (st_old -> time_time ),
74447425 .time_struct_time = Py_XNewRef (st_old -> time_struct_time ),
74457426 .time_strftime = Py_XNewRef (st_old -> time_strftime ),
74467427 };
@@ -7487,7 +7468,6 @@ init_state(datetime_state *st, PyObject *module, PyObject *old_module)
74877468 return -1 ;
74887469 }
74897470
7490- st -> time_time = NULL ;
74917471 st -> time_struct_time = NULL ;
74927472 st -> time_strftime = NULL ;
74937473
@@ -7500,7 +7480,6 @@ traverse_state(datetime_state *st, visitproc visit, void *arg)
75007480 /* heap types */
75017481 Py_VISIT (st -> isocalendar_date_type );
75027482
7503- Py_VISIT (st -> time_time );
75047483 Py_VISIT (st -> time_struct_time );
75057484 Py_VISIT (st -> time_strftime );
75067485
@@ -7519,7 +7498,6 @@ clear_state(datetime_state *st)
75197498 Py_CLEAR (st -> us_per_week );
75207499 Py_CLEAR (st -> seconds_per_day );
75217500 Py_CLEAR (st -> epoch );
7522- Py_CLEAR (st -> time_time );
75237501 Py_CLEAR (st -> time_struct_time );
75247502 Py_CLEAR (st -> time_strftime );
75257503 return 0 ;
0 commit comments