Conversation
|
Went through this one carefully and it holds up. The bug is real on >>> ordinal(10**400)
OverflowError: int too large to convert to float
>>> ordinal(-(10**400))
OverflowError: int too large to convert to floatThe cause is exactly as the PR implies: Reordering to try I checked the fallback ordering preserves existing behaviour across the awkward inputs rather than just the happy path:
All match
One note for anyone else verifying this locally: if you have Unrelated to the correctness of this change, but since it touches the same function: #405 is fixing the negative-number suffix ( |
ordinal()promises to accept anything thatint()can convert, but it checks the input as a float first. For example,ordinal(10**400 + 1)raisesOverflowError, while passing the same integer as a string orDecimalreturns"+Inf". These are finite values and should receive an ordinal suffix.Changes proposed in this pull request:
__int__but no__float__to work as documented.__int__-only object, plus compatibility checks for fractional values, booleans and invalid integer strings.Testing on Windows with Python 3.12: the 19 new regression cases fail before the fix and pass afterward. The full suite, including doctests, passes with 812 passed and 69 translation-related skips because some compiled catalogs and gettext tools are unavailable. Ruff, Black and Mypy also pass locally; the full prek hook suite and other Python/platform combinations were not run.