Title: Share builtin standard-stream callback controls by youknowdot · Pull Request #9720 · RustPython/RustPython · GitHub
Open Graph Title: Share builtin standard-stream callback controls by youknowdot · Pull Request #9720 · RustPython/RustPython
X Title: Share builtin standard-stream callback controls by youknowdot · Pull Request #9720 · RustPython/RustPython
Description: Summary Group CPython 3.15 print/input callback controls in 167 changed lines across two production Rust files. Retain the existing derived argument binders while keeping print options as raw owners. Reject unknown keywords before flush truth conversion, resolve stdout afterward, and validate separator/end only after the stdout=None short-circuit. Borrow printed objects through every write and final flush. Preserve separator/end str-subclass conversion and contextual validation errors. Share a PyFile_WriteObject-style helper between print pieces and noninteractive input prompts. Resolve write before stringification, retain the selected callable through conversion, then release converted text, callable and write result in order. Accept arbitrary input prompts. Select and retain stdin/stdout/stderr directly from the sys dictionary, reject missing/None streams, and emit the input audit event before stream callbacks. Distinguish ignored fileno call failures from propagated integer conversion failures. Use platform C-long width, and check stdin's actual terminal status before invoking stdout.fileno. Preserve input flush-error handling, newline/EOF behavior and the existing rustyline/PTY safeguards. Convert interactive prompts once and emit the result audit event after rustyline success. Improve non-string readline diagnostics through the existing qualified-type helper. Validation Reference: CPython d220409a13b77de7a6c30abe16ea90db01528edc, Python/bltinmodule.c, its generated clinic binder, Objects/fileobject.c and Python/sysmodule.c. The pinned CPython oracle passed 47 probes and 10 explicit assertions. Independent review reran it and added seven assertions across three callback/finalizer probes. These are reference/source checks, not execution of RustPython. Independent exact-source review passed, including the final borrowed-option cleanup. Final threaded cargo check passed in 1m06s and all-targets Clippy in 2m21s, with all 12 unchanged baseline diagnostics matching exactly. No warnings were suppressed. Normal commit hooks, rustfmt and git diff --check passed. No tests, Lib files, assertions, expected failures or workflows were changed. Native RustPython execution remains unrun because the required execution guard has not been verified. Full workspace/C-API suites, native differential tests and separate platform/feature graphs remain unrun; hosted CI is pending. Scope and integration The shared file writer performs one lookup per emitted piece, not a cached lookup for the whole print call. Selected streams and raw input/print owners remain alive across callbacks. Caller-wide argument and outer stream teardown beyond the retained lifetimes are not claimed fixed. Existing extremely long separator/end type-name diagnostics are not truncated to CPython's 200-byte limit. Full CPython interactive readline, terminal encoding and fallback parity remain outside scope. The existing rustyline/PTY guard is retained, and no terminal runtime validation was performed. The independent vars exception-masking issue is not included. Existing #9690 shutdown/unraisable handling, #9699 iterator controls and #9718 min/max streaming do not duplicate these behaviors. No general sys stream helper or shutdown behavior is changed. The shared readline diagnostic affects its existing callers without changing successful or EOF behavior. AI-assisted contribution by OpenAI Codex; assistance is disclosed in the commit trailer.
Open Graph Description: Summary Group CPython 3.15 print/input callback controls in 167 changed lines across two production Rust files. Retain the existing derived argument binders while keeping print options as raw owne...
X Description: Summary Group CPython 3.15 print/input callback controls in 167 changed lines across two production Rust files. Retain the existing derived argument binders while keeping print options as raw owne...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9720
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:c16fbc54-a142-b2f9-2b73-06a12e5f664a |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C2AA:269AD9:329CF5C:4394357:6B01F39B |
| html-safe-nonce | dd8ceb43579389002688eb4e487ca9e116827d2c9f23ddc5b111b323b8dad774 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkFBOjI2OUFEOTozMjlDRjVDOjQzOTQzNTc6NkIwMUYzOUIiLCJ2aXNpdG9yX2lkIjoiODU0NTAyODg0NjY5OTgwMzU0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a679c3657e7c1356808f735ae61d2272f0a2216dce575fd092fe2980f99b2de9 |
| hovercard-subject-tag | pull_request:5161424054 |
| 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/9720/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 print/input callback controls in 167 changed lines across two production Rust files. Retain the existing derived argument binders while keeping print options as raw owne... |
| 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