Repository navigation
Preserve native special-method lookup in automatic proxies - #362
Open
mayankdhingra02 wants to merge 1 commit into
Open
mayankdhingra02 wants to merge 1 commit into
mayankdhingra02 wants to merge 1 commit into
Conversation
Resolve forwarded protocol hooks on the wrapped object type and preserve the descriptor binding Python uses for implicit special method calls. Instance attributes and custom attribute lookup should not replace the hooks used by iteration, awaiting, path conversion or descriptors. Signed-off-by: Mayank Dhingra <mayankdhingra02@gmail.com>
Owner
|
Definitely highlights an area which needs more investigation, but the general solution provided is possibly not the right approach to use in all cases. In some cases, rather than chaining to corresponding dunder method, it should be using builtins such as |
This branch has not been deployed
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.
Implicit special-method calls ignore attributes stored on the instance. The forwarding methods added by
AutoObjectProxyandLazyObjectProxycurrently use ordinary attribute access, so the proxy can behave differently from its wrapped object:Look up forwarded hooks in the wrapped object's actual type MRO and preserve Python's descriptor binding rules. The descriptor
__get__hook retains its distinct raw-call behavior. This covers iteration, length hints, awaiting, asynchronous iteration, path conversion, and descriptor operations, including inherited hooks, instance/metaclass overrides, custom descriptors, static/class methods, and reassigned wrapped objects.Added 14 regression tests and a change note. No C implementation or type stub changes.
Validation:
Justfiletest-matrix cell passed viajust test-versionrecipes in isolated copies of the same commit: Python 3.9–3.15 plus 3.14t/3.15t, each with a pure Python installation, the C extension enabled, and the C extension disabled at runtime (27 configurations).just test-mypypassed for all seven target versions; Black and isort checks passed.Local native builds used the installed macOS 15.5 SDK to match the compiler; no build configuration changes are included.