Skip to content

Add per-parse runtime hooks for Unicode names and literal diagnostics - #9

Draft
youknowone wants to merge 9 commits into
RustPython:pr-7-runtime-basefrom
youknowdot:unicode-name-provider
Draft

youknowone wants to merge 9 commits into
RustPython:pr-7-runtime-basefrom
youknowdot:unicode-name-provider

Conversation

@youknowone

Copy link
Copy Markdown
Member

Summary

Add borrowed UnicodeNameProvider and ParseRuntime hooks plus parse_unchecked_with_runtime, keeping existing parse APIs and options unchanged. Unicode preparation occurs at actual named-escape decoding, before name validation; successful literal decoding can dispatch VM warnings. No thread-local state or raw-source rescanning is used.

Decoder abort survives diagnostic checkpoints and suppresses subsequent runtime effects. Ordinary strings, outer f/t-string fragments, and immediate format-spec fragments follow distinct CPython 3.15 semantic-action boundaries. FormatSpecDecodeError preserves the distinction needed by downstream callers for bare Unicode errors.

Dependency and integration

Depends on #7, exact head 19a5e1633451b1f5c28e47f274c72cc854ce6bc4. The temporary base pr-7-runtime-base points to that commit. If #7 changes, this staging base becomes stale and must be reconciled. After #7 merges, retarget this PR to rustpython-0.17.5.

This is parser API work only: RustPython compiler/VM wiring and dependency updates are separate. Existing scalar-only AST surrogate replacement remains a limitation. This is not a claim of complete CPython equivalence.

Verification

  • 257 parser unit tests, 648 fixtures, one inline-generation test, 20 runtime integration tests, and 10 doctests passed.
  • Parser-only strict Clippy, all targets and features, with --no-deps passed; existing AST dependency cfg warnings remain.
  • Changed-file hooks passed.
  • Independent review and finite fresh-process CPython 3.15.2 oracle cases checked syntax/import/warning precedence, recovery, adjacent literals, f/t fragments, and format specifications. Full Ruff workspace and downstream runtime integration were not tested.

AI assistance: OpenAI Codex implemented and reviewed this change.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

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

youknowone and others added 9 commits November 14, 2026 11:59
`from <dotted_name> lazy import` is reported as "use 'lazy from ... '
instead of 'from ... lazy import'", pointed at the `lazy` token, and
`lazy` is consumed so the rest of the import still parses.

Assisted-by: Grok
Parse full expression operands in dictionary and starred generator comprehensions. Preserve conditional-unpacking fallback ordering and recover malformed dictionary unpacking without invalid AST ranges. Add parser fixtures and regenerated snapshots.

Assisted-by: OpenAI Codex:model version unavailable
Update parameter terminology and repeated-star wording without changing
parameter parsing or recovered syntax. Regenerate affected snapshots.

Assisted-by: OpenAI Codex:model-version-unavailable
Diagnose standalone case clauses, assertion assignments, mapping rest
ordering and misplaced lazy imports. Preserve ordinary recovered ASTs
and restore speculative recovery state, including lexical-error paths.

Assisted-by: OpenAI Codex:model-version-unavailable
Project multiline literal-concatenation diagnostics onto the final
literal line while retaining original expression ranges for lexical
error precedence.

Assisted-by: OpenAI Codex:model-version-unavailable
Report the opening brace line for multiline f-string and t-string
replacement fields. Track lexical hint boundaries without changing
recovered syntax or existing PEP 798 deferred-error state.

Assisted-by: OpenAI Codex:model-version-unavailable
Keep decoder failures across diagnostic backtracking and dispatch literal warnings in grammar action order. Preserve format-spec exception provenance and retain standalone parser behavior.

Assisted-by: Codex:gpt-6.1-sol
@youknowdot
youknowdot force-pushed the unicode-name-provider branch from 3abeb93 to 71f341c Compare November 14, 2026 05:02

This branch has not been deployed

No deployments
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.

3 participants