Skip to content

Call descriptor __get__ attributes without pre-binding - #9043

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix-descriptor-raw-get
Oct 10, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix-descriptor-raw-get

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Extract the Python 3.14-compatible descriptor __get__ dispatch fix from #8954. The slot calls the raw type attribute with descriptor, instance and owner instead of binding it first. Existing recursion handling and owned references are preserved.

Extend the existing object snippet for staticmethod, classmethod, callable-object and ordinary-function replacements. No canonical assertions, implementation guards or README changes.

Validation

  • Independently reviewed against CPython 3.14.7 and the pinned megaPR; duplicate check found no existing standalone extraction.
  • Full updated snippet passes CPython 3.14.7 and the freshly built native extraction head; the unchanged implementation fails its new assertion.
  • Native pytest snippet selection: 1 passed.
  • Four existing canonical descriptor tests passed on the extraction head: classmethods, staticmethods, slot descriptors and doc descriptors.
  • Normal commit hooks, VM Clippy and separate CAPI Clippy passed.
  • Hosted platform and full workspace/CAPI CI remain pending.

Implementation extraction, regression and validation were AI-assisted with OpenAI Codex. Draft for cross-platform CI and review.

Summary by CodeRabbit

  • Bug Fixes
    • Descriptor access now calls __get__ with the descriptor, the optional instance, and the optional owning class. Descriptors without __get__ remain unchanged.
    • Corrected handling of static methods, callable descriptors, class methods, and plain functions during descriptor access.

Extract the Python 3.14-compatible descriptor slot dispatch from RustPython#8954. Call the raw type attribute with descriptor, instance and owner, preserving ownership and recursion handling. Extend the existing Python snippet for staticmethod, classmethod, callable-object and ordinary __get__ replacements.

Assisted-by: OpenAI Codex:model identifier unavailable
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d50fb62f-234c-4833-afe4-11ff24ae78be

📥 Commits

Reviewing files that changed from the base of the PR and between 3af5f8a and 7b6fb08.


📒 Files selected for processing (2)
  • crates/vm/src/types/slot.rs
  • extra_tests/snippets/builtin_object.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.



📝 Walkthrough

Walkthrough

descr_get_wrapper now looks up __get__ on the descriptor’s type and calls the raw attribute with the descriptor, optional instance, and optional class. Tests cover several forms of __get__.

Changes

Descriptor get dispatch

Layer / File(s) Summary
Raw __get__ dispatch and tests
crates/vm/src/types/slot.rs, extra_tests/snippets/builtin_object.py
The wrapper calls the raw __get__ attribute or returns the descriptor if it is absent. Tests cover static methods, callable objects, plain functions, and class methods.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: youknowone


Merge Risk: ⚪ Minimal · up to 7b6fb

No actionable merge-blocking issue is identified. Merge after the pending CI checks complete.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: calling descriptor get attributes without pre-binding.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • 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

Comment @coderabbitai help to get the list of available commands.

@youknowone
youknowone marked this pull request as ready for review October 10, 2026 10:53
@youknowone
youknowone enabled auto-merge (squash) October 10, 2026 10:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

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 ✅ Completed 2026-10-10T10:58:34.584506Z 7b6fb08 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b6fb08229

ℹ️ 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".

Comment on lines +166 to +167
# The descriptor slot calls the raw __get__ attribute without binding it first.
class RawGetDescriptor:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the disallowed test-file additions

This block adds new classes, assertions, and test logic to extra_tests/snippets/builtin_object.py, but the repository marks its test-edit restrictions as critical and permits only removing expected-failure/TODO markers or adding expected-failure decorators. Because this is neither allowed form, remove the snippet-file changes and keep this patch to the Rust implementation.

AGENTS.md reference: AGENTS.md:L273-L279

Useful? React with 👍 / 👎.

@youknowone
youknowone merged commit bc495a8 into RustPython:main Oct 10, 2026
21 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