Skip to content

DateTime: Large numbers, infinity and NaN are not handled properly #5840

Description

@pekkaklarck

DateTime has at least two kinds of issues with numbers:

  • Large integers cause problems because they overflow if converted to floats.
  • Infinity and NaN aren't handled properly.

These issues were noticed when fixing a bad error when timedelta conversion failed due to values being too large (#5834) in RF 7.5.1. Fixing many of these issues would have been easier if invalid values (i.e. inf and nan) were rejected in input, but that could have caused backwards incompatibility problems. We expect that using these values is always an error, so changing the behavior in a feature release ought to be fine.

Problems are mostly related to execution failing with bad error messages. Fixes include checking that numbers are finite (i.e. not inf or nan) using math.isfinite and catching OverflowError. Typically in such cases we simply can raise a ValueError with a clear message.

For details about what could/should be changed see this comment to by @d-biehl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions