← Back to Pull requests

Support bytes arguments in float() #1120

Closed
unknown closed this pull request without merging on Oct 26, 2026 16:13 UTC
View on GitHub
unknown unknown commented on Oct 25, 2026 12:18 UTC
Author

float() currently accepts numeric values and strings but rejects bytes, so an ordinary float(b"1.5") raises TypeError where CPython returns 1.5.

This adds bytes conversion for both literal and dynamically allocated inputs, sharing the existing string parser while retaining ASCII-only bytes grammar and the original bytes representation in ValueError messages. Regression coverage includes whitespace, underscores, exponents, infinity/NaN, signed zero, malformed literals, embedded NULs, non-ASCII bytes and quoted/escaped error inputs. The limitations page records the remaining Unicode-digit difference for string arguments.

Refs #983, the bytes-conversion part of item 5 only. Other reported differences and the separate float-rounding PR are outside this change.

Validation on Linux with CPython 3.14.9:

  • The added regression passes on CPython and fails with TypeError on unmodified Monty.

  • All 1,408 Monty/CPython fixture tests pass with the patch; the focused float filter passes 30 tests.

  • Configured pre-commit hooks pass.

  • make format-rs, make lint-rs (including all features), and make lint-py pass.

  • make test-docs passes: 64 Python examples pass and 14 are explicitly skipped by the existing upstream markers; Rust workspace doctests pass.
  • Codex assisted with implementation and test execution. A separate Codex agent independently reviewed the code, regression coverage and documentation, with no blocking findings. No hosted models or external application services were used for verification. macOS and Windows were not tested locally.

    Diff: 197 lines (+147 / -50) across 2 files Reviewer: jaheba Review duration: 1675m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 197 lines diff across 2 files
    0.36
    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.316
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1120"
    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: 36.1% (MEDIUM) · Higher = larger blast radius
    36.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: 14.3% · Safe to merge
    14.3%
    Repository