Title: Align numeric conversion and rounding boundaries by youknowdot · Pull Request #9697 · RustPython/RustPython · GitHub
Open Graph Title: Align numeric conversion and rounding boundaries by youknowdot · Pull Request #9697 · RustPython/RustPython
X Title: Align numeric conversion and rounding boundaries by youknowdot · Pull Request #9697 · RustPython/RustPython
Description: Summary Group CPython 3.15 numeric conversion boundaries in 433 changed production lines (+219/-214): Reuse ArgIntoFloat and ArgIntoComplex to distinguish native scalar conversion from constructor dispatch. Native conversion reads stored float/complex subclass values while constructor-specific special methods retain their required precedence. Normalize float.real/conjugate results and preserve exact complex.complex identity through existing number helpers. Match complex special-method error/warning diagnostics with the shared qualified-type formatter. Normalize Unicode literals before underscore validation, preserve invalid-scalar prefixes, and match embedded-NUL/underscore diagnostics without trimming away information needed by the existing transformer. Replace float subclass's manual positional parser with the existing FuncArgs binder, retaining original positional and keyword owners through conversion/allocation. Release bytearray and generic buffer data guards before invalid float literal repr callbacks, while keeping generic buffer exports alive through error construction. This permits callback mutation without deadlocking and preserves export-related resize rejection. The shared C-API float parser benefits from the same fix. Seven Rust files only. No Python, Lib, tests, expected-failure markers, or workflows changed. Use exact ties-even float rounding, match decimal-round overflow text, and accept arbitrary nonnegative nextafter step indices through the existing saturated native helper. Reuse native conversion for log/log2/log10, preserving huge-integer retry behavior. Share ceil/floor conversion and descriptor-miss handling with trunc through existing special-method lookup. Stream fsum conversions through the existing numerical algorithm, stop before later callbacks after intermediate overflow, and allocate the result before releasing the iterator. Keep numeric diagnostics/warnings compatible with the shared WTF-8 formatter without duplicating type-name logic. Reference and validation Compared with CPython commit d220409a13b77de7a6c30abe16ea90db01528edc: complex conversion, float conversion, and numeric underscore parsing. 13,787 bounded CPython/source-model assertions passed across scalar callbacks, warnings, errors, identities, owner cleanup, Unicode strings and all four shared normalizer consumers. Independent review added 112 CPython observations and 78 NUL boundary assertions, and found a Unicode/NUL diagnostic regression in the initial candidate that is corrected in this final composition. These are reference/model checks, not execution of the Rust implementation. The rounding companion passed 53,508 further CPython/source-model checks and 116,945 independent assertions using separate integer-round, rational decimal-round and signed-rank nextafter models. These cover signed zero, NaN payloads, infinity, adjacent-to-half floats, bounded huge indices, and error/callback ordering. Independent composition review verified the original conversion group is unchanged outside the narrow companion hunks. The native math companion passed 4,195 additional bounded CPython/source-model comparisons and 39 independent checks against mathmodule.c. Exact review verified original conversion/rounding content outside intended hunks and compatibility with #9666. Independent exact-source review passed. Final focused host-env/VM/stdlib threading cargo check, normal all-targets Clippy and ordinary commit hooks passed. Clippy emitted exactly four unchanged main-baseline diagnostics: one POSIX needless-collect and three ElementTree lints. Strict -D warnings remains blocked by that baseline; no warnings were suppressed. No native RustPython execution was attempted. Full workspace/C-API suites and cross-platform runtime checks remain unrun; hosted CI is required. The buffer-callback follow-up passed 35 bounded pinned-CPython assertions covering bytearray mutation/reentry, generic export retention, Python buffer release order, repr exceptions and success/failure cleanup. Exact-source independent review confirmed that all data guards end before callbacks while export ownership survives error creation. Final follow-up threaded cargo check passed in 1m05s and all-targets Clippy in 2m14s, with exactly the same four baseline diagnostics. Normal commit hooks and diff checks passed. Native RustPython and C-API runtime execution remain unrun; hosted validation is pending. Remaining limits The existing ordinary float constructor's keyword-versus-arity diagnostic precedence remains outside this conversion group. Formatting consumers now preserve WTF-8; the shared helper migration itself is tracked in #9700. Native float conversion still has its existing missing-type-name precision difference for unusually long names. Other numeric arithmetic and extreme allocating integer-round behavior remain outside scope. No runtime expected failure is claimed resolved without execution. AI-assisted contribution by OpenAI Codex, disclosed in the commit trailer. Summary by CodeRabbit Bug Fixes Improved numeric conversions for floats and complex numbers, including handling of special conversion methods and complex subclasses. Updated rounding and truncation behavior for exact values, custom numeric types, and values too large to represent. Improved error reporting for invalid numeric conversions and overflow in summation. Corrected handling of large step counts in nextafter and underscores in numeric strings containing a null character.
Open Graph Description: Summary Group CPython 3.15 numeric conversion boundaries in 433 changed production lines (+219/-214): Reuse ArgIntoFloat and ArgIntoComplex to distinguish native scalar conversion from constructo...
X Description: Summary Group CPython 3.15 numeric conversion boundaries in 433 changed production lines (+219/-214): Reuse ArgIntoFloat and ArgIntoComplex to distinguish native scalar conversion from constructo...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9697
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:6b03a88f-2fd9-3e9b-3b20-fad5bf421445 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BDEE:1CCECA:12796C8:189D358:6B01F932 |
| html-safe-nonce | 7cb654be9e4eaa650fd0336745a02e1648f06f5f040ade4103e6562e068b6b94 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREVFOjFDQ0VDQToxMjc5NkM4OjE4OUQzNTg6NkIwMUY5MzIiLCJ2aXNpdG9yX2lkIjoiODY4NTIwMTI2MzM4Nzg2NzQ0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f6dfa3fad47a2dab5c08a87373c9366b38723282f64282a957081ba964a0a2a8 |
| hovercard-subject-tag | pull_request:5152940212 |
| 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/9697/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 Group CPython 3.15 numeric conversion boundaries in 433 changed production lines (+219/-214): Reuse ArgIntoFloat and ArgIntoComplex to distinguish native scalar conversion from constructo... |
| 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