⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align text and bytes argument and buffer controls - #9698

Draft
youknowdot wants to merge 3 commits into
RustPython:mainfrom
youknowdot:fix/text-bytes-controls-20261104
Draft

youknowdot wants to merge 3 commits into
RustPython:mainfrom
youknowdot:fix/text-bytes-controls-20261104

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Group related CPython 3.15 text/bytes controls in 357 substantive changed lines (+200/-157):

  • Share startswith/endswith argument conversion and validate affix items before invalid-range short-circuits, preserving tuple success short-circuiting and exporter errors.
  • Reuse one borrowed bytes/buffer helper for bytes affixes and translation, including direct bytes-subclass access where CPython bypasses buffer overrides.
  • Make bytes/bytearray maketrans use the last mapping for duplicate source bytes and the native length-error diagnostic.
  • Preserve bytes.translate table/delete buffer acquisition, mutation visibility and release order. Return unchanged exact bytes by identity while normalizing subclasses.
  • Validate bytes results before fallback conversion and fix exact bytes.bytes identity.

Four production Rust files only. No Python, Lib, test, expected-failure marker or workflow changes. Partition/rpartition remain unchanged: pinned CPython intentionally retains the supplied separator object.

Reference and validation

Compared with CPython commit d220409a13b77de7a6c30abe16ea90db01528edc: bytes implementation, bytes helpers, and Unicode implementation.

50,330 bounded CPython/source-model assertions and 12,028 independent assertions passed. Coverage includes Unicode/surrogate bounds, tuple item validation, repeated mappings, bytes/bytearray consumers, exact/subclass identities and PEP 688 buffer acquisition/release callbacks with mutation and error paths. These are reference/model checks, not Rust implementation execution.

Independent exact-source review passed, including the final two lazy-default Clippy corrections. Bytearray #9694 composition passed git apply --check. 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.

Native RustPython execution was not performed because the required execution guard has not been verified. Full workspace/C-API suites and cross-platform runtime validation remain unrun. Hosted CI is required; no expected failure is claimed resolved without runtime evidence.

Remaining limits

The existing qualified-type-name formatter does not preserve surrogate-containing type metadata. Generic binder diagnostics and pre-existing bytearray translation/export behavior outside these shared changes remain unchanged. Older architecture/GC/fallible-allocation PRs overlap some files and may need later textual reconciliation; no duplicate behavior fix was found in the 210-PR overlap audit.

AI-assisted contribution by OpenAI Codex, disclosed in the commit trailer.

Shared type-name compatibility

The bytes constructor diagnostic uses the existing WTF-8 concatenation helper so it remains lossless when composed with #9700. Other text/bytes control-flow changes are byte-identical to the previously reviewed head. Independent in-memory composition review verified the exact previous head plus this narrow formatting change. Final focused host-env/VM/stdlib threading check, normal all-targets Clippy and ordinary hooks passed; the same four unchanged baseline diagnostics remain. No new runtime execution or test changes are claimed.

Share affix validation and buffer access while preserving translation callbacks, duplicate mappings, and bytes conversion identities.

Assisted-by: OpenAI Codex:model version not exposed
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Use the shared lossless concatenation helper so the qualified-name migration composes without restoring Rust Display formatting.

Assisted-by: OpenAI Codex:model version not exposed
@codspeed

codspeed Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:fix/text-bytes-controls-20261104 (b72e268) with main (3485237)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Preserve both buffer and bytes-or-string argument imports while integrating the upstream hex separator conversion.

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