← Back to Pull requests

Cap float format precision at `INT_MAX - 1024` like CPython 3.14.8 #1002

Closed
unknown closed this pull request without merging on Oct 09, 2026 11:42 UTC
View on GitHub
unknown unknown commented on Oct 09, 2026 11:12 UTC
Author

CI's setup-python now resolves 3.14 to CPython 3.14.8, which bounds the precision of every float presentation by DOUBLE_TO_STRING_PRECISION_MAX (INT_MAX - 1024) and raises ValueError: precision too big above it, before looking at the value. Two test cases used 2**31 - 1 and so failed on the CPython side in test-rust.

  • Apply the same cap in the format-spec formatter (fstring.rs) for floats, complex values and ints under a float presentation, and in the % formatter for str and bytes templates. inf/nan are rejected too, matching CPython.

  • Add value_error_precision_too_big to exception_private.rs.

  • Move the two asserts to the largest accepted precision and add boundary error cases to the four format test files, plus a check that a str precision stays unbounded.
  • Verified against a standalone CPython 3.14.8 build locally; note a local 3.14.7 still accepts up to INT_MAX, so the new error asserts need 3.14.8 on the CPython side.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01RtPaQCAGccBo8izUqsEGRr

    <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Caps float format precision at INT_MAX - 1024 to match CPython 3.14.8, raising ValueError: precision too big above it before inspecting the value.

  • CI's setup-python now checks for the newest 3.14 patch so all OS jobs agree on 3.14.8; the macOS runner was preinstalling 3.14.7, whose float-to-string conversion accepts up to INT_MAX.

  • Applies the cap in the format-spec and % formatters for str and bytes templates, covering floats, complex values, ints under a float presentation, and inf/nan.

  • Adds MAX_FLOAT_PRECISION and a value_error_precision_too_big helper.

  • Moves the two test asserts to the largest accepted precision, adds boundary error cases to the four format test files, and checks that str precision stays unbounded.
  • <sup>Written for commit ccbd5ab0bac125584099fc050a5668dfeff5d98a. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/1002?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/pydantic/monty/1002?returnTo=https%3A%2F%2Fgithub.com%2Fpydantic%2Fmonty%2Fpull%2F1002&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    Diff: 393 lines (+294 / -99) across 4 files Reviewer: samuelcolvin Review duration: 30m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 393 lines diff across 4 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.358
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #1002"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19% · Safe to merge
    19%
    Repository