Skip to content

OverflowError using datetime.fromtimestamp with a large negative number #2841

@samuelcolvin

Description

@samuelcolvin

🐛 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions