Skip to content

Share typing representation and GenericAlias controls - #9711

Merged
youknowone merged 3 commits into
RustPython:mainfrom
youknowdot:fix/genericalias-controls-20261104
Nov 6, 2026
Merged

youknowone merged 3 commits into
RustPython:mainfrom
youknowdot:fix/genericalias-controls-20261104

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Align GenericAlias controls and share the Python 3.15 type-representation writer across GenericAlias, Union and constant annotation evaluators. The combined change spans three Rust files (+163/-182).

  • Release the iterator's mutex before constructing its starred alias or dropping the original owner, so subclass finalizers can reenter the exhausted iterator.
  • Preserve raw tuple-subclass equality results and CPython's inequality handling. Reconstruct the actual GenericAlias subtype in reduce/copy/pickle paths.
  • Replace three divergent type formatters with one WTF-8 writer. Preserve optional-attribute lookup errors and short-circuits, non-string names, surrogate characters, and temporary-owner cleanup. Attribute probes release their values before the next callback.
  • Preserve the public writer's extra __str__ call on returned str subclasses, after name-attribute cleanup. This call can change output or raise and must not be replaced with raw string copying.
  • Match annotation tuple formatting, including (int) for a singleton tuple, and preserve Unicode in ConstEvaluator's own repr and Union's subclassing diagnostic.

Validation

Pinned reference: CPython d220409a13b77de7a6c30abe16ea90db01528edc, including typevarobject.c, genericaliasobject.c and unicode_writer.c.

  • Independent source/ownership review passed. The expanded independent oracle passed 36 groups, a separate focused oracle passed 18 groups, and the previous 10 GenericAlias groups still passed. These are external CPython reference checks, not native RustPython runtime results.
  • Final threaded cargo check passed (1m07s) and all-targets Clippy passed (2m21s), with exactly the same 12 existing baseline diagnostics and no new warnings.
  • Rustfmt, diff checks and normal commit hooks passed without bypass.

Limits and integration

Native RustPython execution remains unperformed because its required safety guard is not verified; hosted runtime CI remains necessary. The separate non-threaded/WASM graph and full workspace/C-API test suite were not run under the current disk constraint. No repository tests, markers, Lib files or workflows changed.

#9714 separately fixes Union construction and comparison; #9687 fixes TypeAliasType constructor binding; #9700 changes qualified-name diagnostics. Exact-source composition with those changes was clean and reviewed, but the combined branches were not compiled. Broader payload ownership work in #8944/#8939 may require textual reconciliation and does not implement these controls.

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

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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 one writer for aliases, unions, and constant annotations while preserving Unicode, returned string callbacks, and temporary owner order.

Assisted-by: OpenAI Codex:model version not exposed
@youknowdot youknowdot changed the title Align GenericAlias controls and iterator ownership Share typing representation and GenericAlias controls Nov 4, 2026
Override the existing rich comparison slot through Comparable, preserving raw equality results and identity-based inequality. Retain a bool-valued cmp adapter for Rust callers without duplicating comparison logic.

Assisted-by: OpenAI Codex:model version not exposed
@youknowone
youknowone marked this pull request as ready for review November 6, 2026 12:50
@youknowone
youknowone merged commit 244569c into RustPython:main Nov 6, 2026
18 of 20 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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.

2 participants