This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2017年06月16日 12:55 by lazka, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg296191 - (view) | Author: Christoph Reiter (lazka) * | Date: 2017年06月16日 12:55 | |
I'm not sure this is a bug since the docs says raising OSError is allowed, but it looks weird to me. On Windows. Using Python 3.4: >>> datetime.datetime.fromtimestamp(0) datetime.datetime(1970, 1, 1, 1, 0) Using Python 3.6.1: >>> datetime.datetime.fromtimestamp(0) OSError: [Errno 22] Invalid argument The first time stamp which works with 3.6 is 86400, so exactly the next day. |
|||
| msg296196 - (view) | Author: Eryk Sun (eryksun) * (Python triager) | Date: 2017年06月16日 14:34 | |
This is due to computing the PEP 495 fold in the function datetime_from_timet_and_us in Modules/_datetimemodule.c. It computes the local time for (timet - max_fold_seconds), which is negative for timestamps less than max_fold_seconds (86400). It's documented that localtime_s [1] fails for negative time values. For example: 0:000> kc 6 Call Site python36_d!localtime_s python36_d!_PyTime_localtime python36_d!local python36_d!datetime_from_timet_and_us python36_d!datetime_from_timestamp python36_d!datetime_fromtimestamp Dereference the time_t* arg (-86400): 0:000> ?? *(int64_t *)@rdx int64 0n-86400 Print the errno_t return value (0x16 is EINVAL): 0:000> pt; r rax rax=0000000000000016 [1]: https://msdn.microsoft.com/en-us/library/a442x3ye.aspx |
|||
| msg296213 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2017年06月16日 17:06 | |
This appears to be a duplicate of issue 29097. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:47 | admin | set | github: 74869 |
| 2017年06月16日 17:06:14 | r.david.murray | set | status: open -> closed superseder: [Windows] datetime.fromtimestamp(t) when 0 <= t <= 86399 fails on Python 3.6 nosy: + r.david.murray messages: + msg296213 resolution: duplicate stage: resolved |
| 2017年06月16日 14:34:01 | eryksun | set | versions:
+ Python 3.7 nosy: + eryksun, belopolsky, tim.peters, paul.moore, tim.golden, zach.ware, steve.dower messages: + msg296196 components: + Library (Lib), Windows type: behavior |
| 2017年06月16日 12:55:21 | lazka | create | |