◐ Shell
clean mode source ↗

Message 284600 - Python tracker

Oh, datetime.datetime.timestamp() also has a bug for values close to 0001-01-01 (year 1), at least in my timezone (CET).

$ ./python -c 'import datetime; datetime.datetime.min.timestamp()'
python: /home/haypo/prog/python/default/Modules/_datetimemodule.c:251: days_before_year: Assertion `year >= 1' failed.
Aborted (core dumped)

datetime_check_args.patch doesn't fix this issue. A solution is to check that year>=1 in utc_to_seconds():

+    if (year < MINYEAR || year > MAXYEAR) {
+        PyErr_SetString(PyExc_ValueError,
+                        "year is out of range");
+        return -1;
+    }

Maybe it would solve the following local() comment:

   /* XXX: add bounds checking */