⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align regular expression substitution contracts - #9676

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:regex-substitution-contracts-20261103
Draft

youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:regex-substitution-contracts-20261103

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

  • Share signed count binding for Pattern.sub and subn, matching the Py_ssize_t conversion domain.
  • Preserve unused mixed-type literals and literal-only templates, and omit None results from replacement callbacks.
  • Retain mutable subject exports while releasing byte borrows around callbacks, so in-place mutations affect later searches without allowing resize. Reuse search state and avoid constructing matches for literal replacements.

Uses the existing derived argument binder, template compiler, and search engine; no per-function FuncArgs parsing.

Reference: CPython 3.15.0 substitution implementation and Clinic binders.

Validation

  • Bounded CPython 3.15 reference probes cover count conversion and overflow, callback results, empty matches, mixed literals, live mutable subjects, export lifetime, and callback match metadata.
  • Independent source review and formatting/whitespace checks passed.
  • Focused VM, host-env and stdlib check and strict Clippy with rustpython-stdlib/threading: passed. Normal repository commit hooks also passed.
  • A separate default-feature strict Clippy attempt encountered the unchanged _ctypes Arc<BufferWrite> non-Send/Sync lint. The unused helper introduced by this refactor was removed, not suppressed.
  • RustPython runtime, full workspace/C-API suites, and cross-platform execution were not run. No test, Lib, workflow, or marker edits.

AI assistance: OpenAI Codex performed source comparison, implementation, reference probes, and independent source review; model version was not exposed.

Reuse signed count binding and shared replacement conversion paths.
Handle None callback results and unused mixed-type literals, and retain
subject exports without holding byte borrows across callbacks. Reuse
search state while observing in-place mutable-subject changes.

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

coderabbitai Bot commented Nov 3, 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

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