-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
bpo-29097: Forego fold detection on windows for low timestamp values #2385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
8f163d3
488bc8b
008778f
636ec5d
9202447
7241000
64ae51a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix bug where ``datetime.fromtimestamp`` erronously throws an OSError on | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better if we can link to the :meth:`datetime.fromtimestamp`
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OSError -> :exc:`OSError`
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh cool, didn't know we could use documentation syntax here. |
||
| Windows for values between 0 and 86400 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add "Patch by Ammar Askar.". |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4627,15 +4627,16 @@ datetime_from_timet_and_us(PyObject *cls, TM_FUNC f, time_t timet, int us, | |
| /* local timezone requires to compute fold */ | ||
| if (tzinfo == Py_None && f == _PyTime_localtime | ||
| /* On Windows, passing a negative value to local results | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style nit: Please use the existing comment style in the file: /* first line
* second line
* / |
||
| * in an OSError because localtime_s on Windows does | ||
| * not support negative timestamps. Unfortunately this | ||
| * means that fold detection for time values between | ||
| * 0 and max_fold_seconds will result in an identical | ||
| * error since we subtract max_fold_seconds to detect a | ||
| * fold. However, since we know there haven't been any | ||
| * folds in the interval [0, max_fold_seconds) in any | ||
| * timezone, we can hackily just forego fold detection | ||
| * for this time range on Windows. */ | ||
| * in an OSError because localtime_s on Windows does | ||
| * not support negative timestamps. Unfortunately this | ||
| * means that fold detection for time values between | ||
| * 0 and max_fold_seconds will result in an identical | ||
| * error since we subtract max_fold_seconds to detect a | ||
| * fold. However, since we know there haven't been any | ||
| * folds in the interval [0, max_fold_seconds) in any | ||
| * timezone, we can hackily just forego fold detection | ||
| * for this time range. | ||
| */ | ||
| #ifdef MS_WINDOWS | ||
| && (timet - max_fold_seconds > 0) | ||
| #endif | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this test be marked as Windows-only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily, while the bug is windows specific, if you look at the bpo thread you'll see there were no folds during this time. Therefore, this can just act as another unit test for fold detection on other platforms while being a regression test on windows.