Skip to content

Commit 008778f

Browse files
author
Ammar Askar
committed
Add news entry, fix style nits
1 parent 488bc8b commit 008778f

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

Lib/test/datetimetester.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4944,13 +4944,11 @@ def test_fromtimestamp_lord_howe(self):
49444944
self.assertEqual(t0.fold, 0)
49454945
self.assertEqual(t1.fold, 1)
49464946

4947-
49484947
def test_fromtimestamp_low_fold_detection(self):
49494948
# Ensure that fold detection doesn't cause an
49504949
# OSError for really low values, see bpo-29097
49514950
self.assertEqual(datetime.fromtimestamp(0).fold, 0)
49524951

4953-
49544952
@support.run_with_tz('EST+05EDT,M3.2.0,M11.1.0')
49554953
def test_timestamp(self):
49564954
dt0 = datetime(2014, 11, 2, 1, 30)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix bug where ``datetime.fromtimestamp`` erronously throws an OSError on
2+
Windows for values between 0 and 86400

Modules/_datetimemodule.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4627,15 +4627,16 @@ datetime_from_timet_and_us(PyObject *cls, TM_FUNC f, time_t timet, int us,
46274627
/* local timezone requires to compute fold */
46284628
if (tzinfo == Py_None && f == _PyTime_localtime
46294629
/* On Windows, passing a negative value to local results
4630-
* in an OSError because localtime_s on Windows does
4631-
* not support negative timestamps. Unfortunately this
4632-
* means that fold detection for time values between
4633-
* 0 and max_fold_seconds will result in an identical
4634-
* error since we subtract max_fold_seconds to detect a
4635-
* fold. However, since we know there haven't been any
4636-
* folds in the interval [0, max_fold_seconds) in any
4637-
* timezone, we can hackily just forego fold detection
4638-
* for this time range on Windows. */
4630+
* in an OSError because localtime_s on Windows does
4631+
* not support negative timestamps. Unfortunately this
4632+
* means that fold detection for time values between
4633+
* 0 and max_fold_seconds will result in an identical
4634+
* error since we subtract max_fold_seconds to detect a
4635+
* fold. However, since we know there haven't been any
4636+
* folds in the interval [0, max_fold_seconds) in any
4637+
* timezone, we can hackily just forego fold detection
4638+
* for this time range.
4639+
*/
46394640
#ifdef MS_WINDOWS
46404641
&& (timet - max_fold_seconds > 0)
46414642
#endif

0 commit comments

Comments
 (0)