Skip to content

Commit 986bb0a

Browse files
authored
pythongh-83714: Fix stat_nanosecond_timestamp() for 32-bit time_t (python#141069)
1 parent f458ac0 commit 986bb0a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Modules/posixmodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,13 +2634,14 @@ _posix_free(void *module)
26342634
static PyObject *
26352635
stat_nanosecond_timestamp(_posixstate *state, time_t sec, unsigned long nsec)
26362636
{
2637-
#if SIZEOF_LONG >= 8
2637+
#if SIZEOF_TIME_T == 4
2638+
return PyLong_FromLongLong(sec * SEC_TO_NS + nsec);
2639+
#else
26382640
/* 1677-09-21 00:12:44 to 2262-04-11 23:47:15 UTC inclusive */
26392641
if ((LLONG_MIN/SEC_TO_NS) <= sec && sec <= (LLONG_MAX/SEC_TO_NS - 1)) {
26402642
return PyLong_FromLongLong(sec * SEC_TO_NS + nsec);
26412643
}
26422644
else
2643-
#endif
26442645
{
26452646
PyObject *ns_total = NULL;
26462647
PyObject *s_in_ns = NULL;
@@ -2663,6 +2664,7 @@ stat_nanosecond_timestamp(_posixstate *state, time_t sec, unsigned long nsec)
26632664
Py_XDECREF(s_in_ns);
26642665
return ns_total;
26652666
}
2667+
#endif
26662668
}
26672669

26682670
static int

0 commit comments

Comments
 (0)