-
Notifications
You must be signed in to change notification settings - Fork 108
Add type argument to descriptor __get__ #2754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
beverlylytle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
cf51fcd to
ccbc0ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a CPython segfault issue (python/cpython#132747) by correctly calling the descriptor protocol's __get__ method with both required arguments. The change ensures that when unbinding builtin methods, the type argument is explicitly passed to __get__.
- Modified the descriptor
__get__call to include the type argument:__get__(slf, type(slf))instead of__get__(slf)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kshitij12345
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks @shino16
riccardofelluga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Way to go! Great catch!
For info, what changes under the hood when we give the type to the get method?
|
Thanks! I believe there is no change. The official doc says
(copied from #2677 (comment)) |
|
@KaelanDt This is ready for your review. Thanks! |
This PR makes
_call_dispatchuse__get__(slf, type(slf))instead of__get__(slf), working around a CPython segfault (python/cpython#132747).This will eliminate the segmentation fault mentioned in #2677 (comment). From Python 3.13.3 this workaround will no longer be necessary, but I think we can keep it anyway.