Accept the Windows-specific error message in the overflow timestamp test - #3039
Closed
afonsojanu wants to merge 1 commit into
Closed
Accept the Windows-specific error message in the overflow timestamp test#3039afonsojanu wants to merge 1 commit into
afonsojanu wants to merge 1 commit into
Conversation
from_timestamp() wraps any OSError from datetime.fromtimestamp() into a ValueError with its own fixed message, "Error converting value to datetime". On Linux and macOS this particular overflow value never takes that path since CPython there raises a plain ValueError about the resulting year being out of range, so the test's regex never had to account for the other branch. On Windows, fromtimestamp() raises OSError for the same input, which lands on that wrapped message instead, and the old regex didn't match it, failing CI there on every platform-matrix build. Broadened the match to also accept that message, since it's exactly what from_timestamp()'s own exception handling produces here and means the same thing as the other two: the value was rejected because it was out of range.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2999
test_from_timestamp_with_overflow_value only checked for the error message datetime.fromtimestamp() produces on Linux and macOS for this particular overflow value, a plain ValueError about the year being out of range. On Windows, the same call raises OSError instead, which from_timestamp() already catches and re-raises as ValueError("Error converting value to datetime"), a perfectly valid outcome that the test's regex just never accounted for. That's exactly the failure shown in the linked issue's Windows CI log.
Broadened the match to also accept that message. Confirmed the existing behavior on my own machine still passes as before (this platform hits the ValueError branch, not OSError), and separately simulated the OSError branch by monkeypatching datetime.fromtimestamp to confirm the new alternative in the regex matches the literal message from_timestamp() produces there, since I don't have a Windows machine to reproduce the CI failure directly.
Full test suite (1190 tests) passes, ruff check and ruff format both clean at the pinned v0.16.1.