-
Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-38444: [Python] Handle out-of-range date scalar repr - #51290
Open
emecii wants to merge 1 commit into
Open
Conversation
Generated-by: OpenAI Codex
@github-actions
github-actions
Bot
added
Component: Python
awaiting review
Awaiting review
labels
Sep 10, 2026
jorisvandenbossche
commented
Sep 11, 2026
Member
Date32 and Date64 scalars outside Python's calendar range now render as <value out of range: ...> instead of raising from str() or repr(). This is not a breaking API change.
Why does this still result in "value out of range" ? You mention that "Arrow can format the values safely", but so the C++ formatter will still give that out of range text instead of a formatted date?
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.
Uh oh!
There was an error while loading. Please reload this page.
Rationale for this change
Valid Date32 and Date64 values can fall outside Python's datetime.date range. Their scalar str and repr paths currently call as_py() and raise OverflowError, even though Arrow can format the values safely.
What changes are included in this PR?
Date32Scalar and Date64Scalar now preserve their existing formatting for Python-representable dates and fall back to the Arrow C++ scalar representation only when conversion raises OverflowError. The as_py() behavior is unchanged.
Boundary regressions cover the minimum and maximum storage values for both date types, plus an in-range leap-day case.
Are these changes tested?
Yes.
Are there any user-facing changes?
Date32 and Date64 scalars outside Python's calendar range now render as <value out of range: ...> instead of raising from str() or repr(). This is not a breaking API change.
Closes #38444.
AI assistance
This PR was prepared with OpenAI Codex assistance for investigation, implementation, and test execution. The change is limited to the date scalar formatting paths and their regression tests.