Skip to content

Align descriptor initialization and abstract controls with Python 3.15 - #9707

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/descriptor-controls-20261104
Nov 5, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/descriptor-controls-20261104

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

  • Initialize classmethod/staticmethod callable metadata in __new__, preserve identity no-ops, and reload the callable after replacement finalizers reenter initialization.
  • Dispatch property copies through the actual subtype constructor, including arbitrary return values, and copy the current name after constructor callbacks.
  • Match property initialization publication, owner-release, document lookup/error, and name reset/deletion ordering while preserving the existing lock-safe name replacement.
  • Share abstract-marker truth/error handling between the three descriptors and _abc; descriptor abstract markers are read-only.

This Python 3.15 compatibility group changes five Rust files (+125/-170). It is independent of #9453's native staticmethod metadata path; its constructor/metadata additions must be preserved when composing. Broad GC ownership work may require integration care around the existing property name lock-release helper.

Validation

  • Source comparison against CPython d220409a13b77de7a6c30abe16ea90db01528edc (funcobject.c, descrobject.c, object.c, and _abc.c).
  • External CPython 3.15.0 bounded oracle: wrapper constructors, same-callable metadata preservation, reentrant replacement/finalizer ordering, property subtype construction/arbitrary returns, name reset/deletion, partial state and doc errors, abstract truth/errors/read-only behavior, and ABC marker errors passed.
  • Independent review of the frozen patch found no source or lifecycle blockers, including incoming-owner retention and release outside locks.
  • Threaded cargo check and all-target Clippy passed with no candidate-file diagnostics. Twelve existing diagnostics remain in unchanged host_env/socket.rs (eight), VM POSIX (one), and ElementTree (three); no lint suppressions were added.
  • Rustfmt, diff check, and normal commit hooks passed.

Native RustPython runtime execution was not performed because its required safety guard is not verified. No repository tests, markers, or workflow files were changed. Hosted CI remains required.

@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


impl PyObject {
/// Return the truth value of an optional abstract-method marker.
pub(crate) fn is_abstract(&self, vm: &VirtualMachine) -> PyResult<bool> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct implementation? isn't there a flag in CPython?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this matches CPython’s _PyObject_IsAbstract(): it reads the optional __isabstractmethod__ attribute and applies PyObject_IsTrue(). A missing attribute returns false; lookup and truth-conversion errors propagate. classmethod, staticmethod, and _abc use that helper for the wrapped callable or class member.

Py_TPFLAGS_IS_ABSTRACT is a separate class-level flag, updated from __abstractmethods__ and used to prevent instantiating abstract classes. It does not represent an arbitrary object’s abstract-method marker, so it cannot replace the attribute lookup here.

Reference: CPython object.c (_PyObject_IsAbstract).

@youknowone
youknowone marked this pull request as ready for review November 5, 2026 14:42
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-05T14:42:49.149611Z
We couldn’t complete this review. Comment @codex review to try again.
3125f01 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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.

@youknowone
youknowone merged commit a2b2e98 into RustPython:main Nov 5, 2026
18 of 20 checks passed
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