gh-144989: Expose special method lookup at Python level#144990
Open
tanloong wants to merge 17 commits intopython:mainfrom
Open
gh-144989: Expose special method lookup at Python level#144990tanloong wants to merge 17 commits intopython:mainfrom
tanloong wants to merge 17 commits intopython:mainfrom
Conversation
Member
ZeroIntensity
left a comment
There was a problem hiding this comment.
This needs a "What's New in Python 3.15" entry.
Misc/NEWS.d/next/Library/2026-02-19-17-46-59.gh-issue-144989.JAuJyG.rst
Outdated
Show resolved
Hide resolved
Contributor
Author
|
@ZeroIntensity Thank you for your review! I've updated the code accordingly. Could you please take another look when you have time? Thanks again! |
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.
This exposes
_PyObject_LookupSpecialMethod()astypes.lookup_special_method(obj, attr).I am not quite sure which one between the two similar funtions in
Objects/typeobject.cshould be preferred to be exposed:_PyObject_LookupSpecial()or_PyObject_LookupSpecialMethod(). I chose the_PyObject_LookupSpecialMethod()because it is the function that is called byLOAD_SPECIAL. So I suppose using this one is more consistent with the CPython interpreter when parsing with-statements (#144386 (comment)).However, I am open to adjusting the PR to expose
_PyObject_LookupSpecial()instead if that one is more suitable.📚 Documentation preview 📚: https://cpython-previews--144990.org.readthedocs.build/