-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-126417: validate ABC methods on multiprocessing proxy types #126454
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
Conversation
also validate in the tests that ListProxy has all MutableSequence methods and DictProxy has all MutableMapping methods.
This comment was marked as outdated.
This comment was marked as outdated.
I think it's fine that |
Co-authored-by: Alex Waygood <[email protected]>
Yeah, I agree. I had thought it would be free to add it, at which point we might as well. But it's not bad to not have it. |
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.
This seems fine to me. It's not ideal to hardcode the method names in the test -- but it also is probably more trouble than it's worth to try to figure them out dynamically in the test; it's obviously good to keep tests as simple as possible. And it seems pretty unlikely that methods will be added or removed from these ABCs anytime soon, so it's not a massive problem to just hardcode the names.
…ythonGH-126454) Checks that appropriate dunder __ methods exist on the dict and list proxy types. (cherry picked from commit 6ee542d) Co-authored-by: Stephen Morton <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
GH-126674 is a backport of this pull request to the 3.13 branch. |
…ythonGH-126454) Checks that appropriate dunder __ methods exist on the dict and list proxy types. (cherry picked from commit 6ee542d) Co-authored-by: Stephen Morton <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
GH-126675 is a backport of this pull request to the 3.12 branch. |
…ython#126454) Checks that appropriate dunder __ methods exist on the dict and list proxy types. Co-authored-by: Alex Waygood <[email protected]>
…ython#126454) Checks that appropriate dunder __ methods exist on the dict and list proxy types. Co-authored-by: Alex Waygood <[email protected]>
In a similar situation, @JelleZijlstra asked about making sure all the relevant methods existed for
contextvars.Context
being registered toMapping
: #126451 (comment)After that, I circled back to do the same for ListProxy and DictProxy. DictProxy already had everything it needed, but ListProxy is missing
__iter__
. In the original version of this MR I added it, but that caused a test failure intest_list_iter
.When
__iter__
is proxied,iter(mylist)
returns a list_iterator object. That behaves differently in some situations than the iterator object currently returned; Seems like it doesn't pick up the modification during iteration thattest_list_iter
checks for. Because of that, I changed this MR to just the test improvement. I think some custom methods would be needed to add__iter__
to ListProxy without changing the behavior.