Repository navigation
Share the lazy Unicode name capsule provider between codecs - #9828
Draft
youknowdot wants to merge 3 commits into
Draft
youknowdot wants to merge 3 commits into
youknowdot wants to merge 3 commits into
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Contributor
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [ ] test: cpython/Lib/test/test_unicodedata.py (TODO: 2) dependencies: dependent tests: (no tests depend on unicode) Legend:
|
Run provider lifecycle checks before Unicode-name use, and compile named escapes at runtime to preserve fresh-cache coverage without subprocesses. Assisted-by: Codex:model-identifier-unavailable
youknowdot
force-pushed
the
fix/unicode-name-provider-20261113
branch
from
November 14, 2026 06:01
640ab1c to
7a45500
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Uses the UCD private-name records from merged #9827; now based directly on main.
Implement CPython's lazy Unicode-name provider for the Unicode codecs:
unicodedata._ucnhash_CAPIcarries an actual immutable two-callback native table, not a placeholder handle.unicode_escapeacquires the provider when it encounters\N, before malformed/incomplete escape validation.namereplacechecks the exception type first, then imports before inspecting its range.Raw capsule creation and pointer/context mutation are now unsafe Rust APIs with explicit protocol, callback, synchronization and lifetime contracts. Their existing callers are adjusted, including C API entrypoints and Windows directory cookies. This does not change the C ABI. Merely matching a capsule name is not claimed to validate an arbitrary pointer.
Scope
Remove only
test_unicodedata_unload_reload's expected-failure marker. The compiler import-failure expected failure remains: a proper Ruff runtime parse hook must also preserve literal warning/error order, speculation and recovery behavior. This PR does not attempt to work around the parser by scanning source text.Current head and verification
Head
7a4550046b8499b86fc24e218d62fcbc8d9e8926is rebased onto main1d17957399ef02dab4a3ed90622d44437acc6fc1, after #9827 and #9831 merged. The provider implementation is unchanged; range-diff shows only surrounding context changed by #9820's Unicode version cleanup. No conflict-resolution behavior change was needed.All additional Python snippet checks now live in
extra_tests/snippets/stdlib_unicode.py. The separatestdlib_unicode_name_provider.pyis removed and the existingstdlib_unicode_shared.pyis renamed/combined. Provider failure/retry/cache checks run before other Unicode-name use. Named-escape compiler checks use runtimeevalof raw source, preventing source compilation from warming the name cache before the lifecycle checks. The harness still starts one fresh interpreter for this file, including WASI; no guest subprocess, skipped assertion or platform exclusion was added.Historical implementation validation
UnicodeMiscTestran 12 tests with one existing skip and the remaining compiler expected failure;UnicodeEscapeTestpassed 15 tests.cargo checkpassed. Independent safety/CPython-parity review completed._ctypes/base.rsArc<BufferWrite>lint; the normal root-package threading configuration passed. No unrelated suppression or ctypes change is included.