From 86116aea967b67471a9dfe8da5d0be8acaa147a3 Mon Sep 17 00:00:00 2001 From: Jad Chaar Date: Sun, 28 Feb 2021 15:04:31 -0500 Subject: [PATCH] Fix overflow on 32-bit Linux systems (#931) --- arrow/constants.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arrow/constants.py b/arrow/constants.py index 1bf36d6c3..22ffe55dc 100644 --- a/arrow/constants.py +++ b/arrow/constants.py @@ -15,14 +15,15 @@ # but will trigger an OverflowError, ValueError, or OSError on Windows _MAX_TIMESTAMP = datetime.max.timestamp() except (OverflowError, ValueError, OSError): # pragma: no cover - # Fallback for Windows if initial max timestamp call fails + # Fallback for Windows and 32-bit systems if initial max timestamp call fails # Must get max value of ctime on Windows based on architecture (x32 vs x64) # https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/ctime-ctime32-ctime64-wctime-wctime32-wctime64 + # Note: this may occur on both 32-bit Linux systems (issue #930) along with Windows systems is_64bits = sys.maxsize > 2 ** 32 _MAX_TIMESTAMP = ( - datetime(3000, 12, 31, 23, 59, 59, 999999).timestamp() + datetime(3000, 1, 1, 23, 59, 59, 999999).timestamp() if is_64bits - else datetime(2038, 1, 18, 23, 59, 59, 999999).timestamp() + else datetime(2038, 1, 1, 23, 59, 59, 999999).timestamp() ) MAX_TIMESTAMP: Final[float] = _MAX_TIMESTAMP