Repository navigation
Preserve function metadata and annotation callback lifetimes - #9162
Conversation
Use the canonical code module path introduced in PyO3 0.30 without suppressing deprecation warnings. Assisted-by: OpenAI Codex:model version unavailable
Preserve function name identity, implicit wrapper metadata and slice generic aliases. Match annotation dictionary and reentrant publication contracts, releasing displaced Python owners outside locks in the required phases. Refresh the matching canonical annotation tests through update_lib. Assisted-by: OpenAI Codex: gpt-6.1-sol
Migrate the complete Python 3.15 test_genericalias file through update_lib. Preserve the full canonical type list and capability guards so normal test runs cover slice subscripting. Assisted-by: OpenAI Codex: gpt-6.1-sol
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters: 2
📒 Files selected for processing: 5
✨ Finishing Touches
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. Comment |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: :4: SyntaxWarning: invalid decimal literal dependencies:
dependent tests: (19 tests)
Legend:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d8adae764
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| generic_types = [type, tuple, list, dict, frozendict, | ||
| set, frozenset, enumerate, memoryview, | ||
| slice, |
There was a problem hiding this comment.
Revert changes to generic-alias test data
For changes under Lib/test, adding frozendict and slice to generic_types changes the test data, while repository policy allows only expected-failure decorator edits. Revert this migrated type-list change rather than modifying the test inputs.
AGENTS.md reference: AGENTS.md:L278-L282
Useful? React with 👍 / 👎.
|
|
||
| f.__annotate__ = lambda x: 42 | ||
| with self.assertRaisesRegex(TypeError, r"__annotate__ returned non-dict of type 'int'"): | ||
| with self.assertRaisesRegex(TypeError, r"__annotate__\(\) must return a dict, not int"): |
There was a problem hiding this comment.
Restore the annotation test oracle
For changes under Lib/test, this assertRaisesRegex rewrite modifies a test assertion, but repository policy permits only adding or removing expected-failure decorators in test files. Restore the assertion and use an allowed marker if the implementation cannot satisfy it so the implementation change does not move its own oracle.
AGENTS.md reference: AGENTS.md:L278-L282
Useful? React with 👍 / 👎.
Summary
Align function/type/module metadata contracts with CPython 3.15 final, with explicit publication and cleanup order when annotation callbacks or finalizers re-enter Python.
Noneas omitted while retaining explicit string/subclass behavior.__new__,__init_subclass__, and__class_getitem__wrappers using the existing wrapping helper.test_type_annotations.pyandtest_genericalias.pyfiles throughscripts/update_libfrom CPythond220409a13b77de7a6c30abe16ea90db01528edc. No hand-edited assertions or removed capability guards.This is a bounded decomposition of #8954, with independently checked callback/finalizer ordering, rather than a wholesale copy of its type implementation.
Base and prerequisite
Based on main
fd5b30eb5e6c1dd24bb98a305b1c5f47fa64820d, verified again on 2026-10-16. The branch includes the exact separatebf076f10c503749521d176b9b757fe5b3088fe63benchmark import fix from #9161, which is still open and needed for strict all-target lint. The metadata changes are the following two commits, ending at3d8adae764d7db2cf593fa58b61f658043970ecd. The prerequisite should disappear from the PR comparison once #9161 is merged/reconciled.Validation
Fresh Linux validation at the exact source above:
cargo clippy --offline --locked -p rustpython -p rustpython-vm --all-targets -- -D warningspassed.cargo build --offline --locked -p rustpython --bin rustpythonpassed. This is a default-feature debug build, with two jobs, debug info disabled and incremental compilation disabled. Workspace artifacts, including pylib, were refreshed before building.BaseTest.test_subscriptablemethod (all of its original parameters, including slice), one separately loaded unchanged canonical descriptor method, six supplemental metadata observations and 15 separately isolated finalizer/re-entry observations.Each case ran in a fresh bounded process with verified actual module origins and the sealed executable. Candidate binary SHA-256:
f8039c49f9e9c61380c9763eff1af4e1e0c19719b45c84714b33e94f89e992f0.Limits
The two canonical files were migrated whole, but no complete canonical test module was executed locally. The GenericAlias result is the full selected method, not the full module. The unchanged external descriptor method and supplemental observations are separate evidence, not additional committed test-file migrations. Full workspace/C-API suites, other platforms, concurrency stress and broad GC/lifetime correctness were not validated by this packet. No broad type-layout, C-API or GC redesign is included.
AI assistance
OpenAI Codex assisted with implementation, independent source review, canonical migration, validation and this draft under maintainer direction. Commit trailers disclose assistance.