question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`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 and platform, 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:closed
  • Created a year ago
  • Comments:29 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
tirancommented, Jul 6, 2022

This cannot be fixed in Python easily because we call libc functions that accept or return time_t. It goes way beyond fromtimestamp. Other functions are also affected as well.

2reactions
sbc100commented, Jul 6, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found