⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align integer conversion and byte controls - #9702

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix/integer-conversion-controls-20261104
Draft

youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix/integer-conversion-controls-20261104

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Align integer conversions and byte controls with CPython 3.15 in 427 changed production Rust lines across five files.

  • Retain derived argument binding for int.from_bytes and int.to_bytes, then perform length, byteorder type, signed truth and byteorder value checks in the native order. Keep raw controls alive through conversion and result construction, and share reverse-parameter cleanup on success and body-level errors.
  • Use the exact bytes fast path, SIMPLE buffer acquisition and existing bytes/iterable fallback in from_bytes. Release temporary exports and returned bytes before integer-subclass construction.
  • Share literal parsing and canonical bytes diagnostics between implicit and explicit-base integer construction. Preserve string repr callbacks, truncate repr by code points, and retain surrogate text.
  • Share __int__/__index__ result checks, normalize deprecated __int__ subclass results to exact integers, and propagate warning errors.
  • Reuse the same strict ssize helper as Align native sequence iterator state and lifecycle #9701 and lossless warning helper as Preserve Unicode in shared qualified type names #9700. These are identical shared helpers, not new per-method parsers.

No Python, Lib, tests, expected-failure markers or workflow changes.

Reference and validation

Compared with CPython commit d220409a13b77de7a6c30abe16ea90db01528edc: integer implementation, generated argument conversions, and numeric protocols.

  • 332 bounded reference assertions plus 11 conversion/lifetime controls and nine independent destruction-order cases. These are CPython/source checks, not RustPython runtime execution.
  • Independent source review corrected early raw-argument release and declaration-order cleanup before publication. Separate source-composition review preserves numeric normalization, lossless qualified names and exactly one shared helper with Align numeric conversion and rounding boundaries #9697, Preserve Unicode in shared qualified type names #9700 and Align native sequence iterator state and lifecycle #9701. Textual conflicts require retaining both PyObject/PyComplex imports and the shared integer result checks; the combined peer composition was not compiled.
  • Focused host-env/VM/stdlib threading cargo check, normal all-targets Clippy, formatting, diff checks and ordinary commit hooks passed. Four Clippy diagnostics match unchanged main: one POSIX needless-collect and three ElementTree lints. No warning suppression; strict -D warnings remains blocked by that baseline.

Native RustPython execution, full workspace/C-API runtime suites and cross-platform tests were not run. Hosted CI remains required.

Remaining boundaries

  • Cleanup follows canonical parameter order. Arbitrarily reordered keyword evaluation and errors during the shared binder itself retain existing binder-level lifetime differences; no full call-stack finalizer parity is claimed.
  • Surrogate-qualified type names depend on the underlying helper migration in Preserve Unicode in shared qualified type names #9700. This PR's formatting accepts both current and migrated helper types.
  • Existing int.from_bytes('text') fallback wording and generic bytes() collection distinctions remain outside scope. Cross-thread scheduling and unrelated allocation timing are unchanged.

AI-assisted implementation and independent review using OpenAI Codex; model version is not exposed.

Assisted-by: OpenAI Codex:model version not exposed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant