cpython: 383c0238b5b0 (original) (raw)

--- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -1989,6 +1989,42 @@ class TestDateTime(TestDate): self.assertEqual(t.second, 0) self.assertEqual(t.microsecond, 7812)

+

+

+

+

+ def test_insane_fromtimestamp(self): # It's possible that some platform maps time_t to double, # and that this test will fail there. This test should

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -57,6 +57,9 @@ Extension Modules Library ------- +- Issue #29100: Fix datetime.fromtimestamp() regression introduced in Python

--- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -120,6 +120,8 @@ static PyTypeObject PyDateTime_TimeType; static PyTypeObject PyDateTime_TZInfoType; static PyTypeObject PyDateTime_TimeZoneType; +static int check_tzinfo_subclass(PyObject *p); + _Py_IDENTIFIER(as_integer_ratio); _Py_IDENTIFIER(fromutc); _Py_IDENTIFIER(isoformat); @@ -400,8 +402,7 @@ check_date_args(int year, int month, int { if (year < MINYEAR || year > MAXYEAR) {

+ self = (PyDateTime_Date *) (type->tp_alloc(type, 0)); if (self != NULL) set_date_fields(self, year, month, day); @@ -689,6 +694,16 @@ new_datetime_ex2(int year, int month, in PyDateTime_DateTime *self; char aware = tzinfo != Py_None;

+ self = (PyDateTime_DateTime *) (type->tp_alloc(type, aware)); if (self != NULL) { self->hastzinfo = aware; @@ -726,6 +741,13 @@ new_time_ex2(int hour, int minute, int s PyDateTime_Time *self; char aware = tzinfo != Py_None;

+ self = (PyDateTime_Time *) (type->tp_alloc(type, aware)); if (self != NULL) { self->hastzinfo = aware; @@ -2500,8 +2522,6 @@ date_new(PyTypeObject *type, PyObject *a if (PyArg_ParseTupleAndKeywords(args, kw, "iii", date_kws, &year, &month, &day)) {

@@ -4203,7 +4213,15 @@ static long long utc_to_seconds(int year, int month, int day, int hour, int minute, int second) {

+

+

@@ -4219,7 +4237,6 @@ local(long long u) "timestamp out of range for platform time_t"); return -1; }

@@ -4516,12 +4534,13 @@ add_datetime_timedelta(PyDateTime_DateTi assert(factor == 1 || factor == -1); if (normalize_datetime(&year, &month, &day,

+

} static PyObject *