`OverflowError` using `datetime.fromtimestamp` with a large negative number
See original GitHub issue🐛 Bug
OverflowError
using datetime.fromtimestamp
with a large negative number
To Reproduce
Using https://pyodide.org/en/stable/console.html
Welcome to the Pyodide terminal emulator 🐍
Python 3.10.2 (main, Apr 9 2022 20:52:01) on WebAssembly VM
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.fromtimestamp(-2147483649)
Traceback (most recent call last):
File "<console>", line 1, in <module>
OverflowError: timestamp out of range for platform time_t
I also get the error using node, see this build
Expected behavior
Outside wasm:
In [1]: datetime.fromtimestamp(-2147483649)
Out[1]: datetime.datetime(1901, 12, 13, 20, 9, 6)
Environment
- Pyodide Version: 0.21.0-alpha.2, also on https://pyodide.org/en/stable/console.html (Is there a way to get pyiodide version inside the interpreter? I tried
sys.version
andplatform
, but couldn’t fine it - Browser version: Version 103.0.5060.53 (Official Build) (arm64) and also node
v18
on x86 - Any other relevant information: See this CI run
Issue Analytics
- State:
- Created a year ago
- Comments:29 (13 by maintainers)
Top Results From Across the Web
Python 3 Timedelta OverflowError - Stack Overflow
from datetime import date, timedelta >>> date.min datetime.date(1 ... value is negative ex: (-11111) or date is too long to fit in the...
Read more >datetime — Basic date and time types — Python 3.11.1 ...
If the normalized value of days lies outside the indicated range, OverflowError is raised. Note that normalization of negative values may be surprising...
Read more >Mongodb allows storing negative Dates, but pymongo cannot ...
When I convert the value -62170156800000 to datetime via currentmillis.com I get "Sun Nov 28 -0001 00:00:00". Can you explain why the ...
Read more >What's New — pandas 0.23.3 documentation - PyData |
We've reverted a 0.23.0 change to comparing a Series holding datetimes and a datetime.date object (GH21152). In pandas 0.22 and earlier, comparing a...
Read more >Data input conversion or overflow error - IBM
Without that conversion the packed fields (especially negative values) will contain a character in the numeric field and that causes the overflow error....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This cannot be fixed in Python easily because we call libc functions that accept or return
time_t
. It goes way beyondfromtimestamp
. Other functions are also affected as well.If we feel strongly we can open an emscripten but to change time_t to be 64-bit… assuming i remember correctly and it doesn’t effect the syscall layer it should be an easy change.