pyodide: `OverflowError` using `datetime.fromtimestamp` with a large negative number
🐛 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.versionandplatform, but couldn’t fine it - Browser version: Version 103.0.5060.53 (Official Build) (arm64) and also node
v18on x86 - Any other relevant information: See this CI run
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 30 (14 by maintainers)
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.
I think the majority vote here is indeed that it works as intended.