Title: Align integer conversion and byte controls by youknowdot · Pull Request #9702 · RustPython/RustPython · GitHub
Open Graph Title: Align integer conversion and byte controls by youknowdot · Pull Request #9702 · RustPython/RustPython
X Title: Align integer conversion and byte controls by youknowdot · Pull Request #9702 · RustPython/RustPython
Description: 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 #9701 and lossless warning helper as #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 #9697, #9700 and #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 #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. Summary by CodeRabbit Bug Fixes Improved integer conversion from strings, bytes, bytearrays, and other bytes-like values, including more consistent handling of buffer inputs. Improved validation of int.from_bytes() and int.to_bytes() arguments, including the order in which invalid values are reported. int.from_bytes() now checks that values returned by __bytes__ are bytes. Limited long input details in integer-conversion errors to 200 characters or bytes. Strict integer subclasses returned by int() or index() now produce a deprecation warning.
Open Graph Description: 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, t...
X Description: 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, t...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9702
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:fc9e0a6d-b351-af08-78e8-ba0bb67dfb35 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9B74:157C65:31C7FA9:4266668:6B01F3A1 |
| html-safe-nonce | c3deeebdda4d72a8edc9e531aa5a6ebff28fd6ed1b6d37083bb2f1e3169415fa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Qjc0OjE1N0M2NTozMUM3RkE5OjQyNjY2Njg6NkIwMUYzQTEiLCJ2aXNpdG9yX2lkIjoiNzI5NTIyNjA5NTUwOTU2NjM3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7152c1f4bf71aad385e1d295e822a50e280b124e03303ac165a03abbdda72ef0 |
| hovercard-subject-tag | pull_request:5154363359 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9702/files |
| twitter:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| og:image:alt | 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, t... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width