-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
add __class_getitem__ to the python implementation of functools.partial #127537
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
add __class_getitem__ to the python implementation of functools.partial #127537
Conversation
This looks reasonable to me. |
I think a NEWS entry is needed for this one. And an issue just for tracking the changes (or pick an issue that was about adding |
@JelleZijlstra If this is approved, is it a candidate for backporting? |
When was the corresponding change made to the C version? I'd support backporting to any version where |
The feature got added as part of #83662, in this commit: cecf049673da. I'm happy to create a tracking issue and treat this as an (unobservable in CPython) bug, if people think that's actually useful. I can also add a news entry but from the perspective of a CPython user this is an unobservable change. |
I think we can just use that issue instead.
Oh, I considered PyPy as being a CPython user in this sense. But maybe it makes sense not to create the NEWS actually (now that I think about it, I think it'd be more confusing than helping). |
Thanks, looks like it got added in 3.9 already. So we should backport to all branches that still get bugfixes (3.12 and 3.13). Yes, please add a NEWS entry. You can use the issue number from the original change or create a new issue. |
I could not find it on the 3.9 branch. are you sure you didn't mix it up with Anyway, I've added a news entry now. |
partial_methods is just passed to the tp_methods of the functools.partial type, is not actually functools.partialmethod |
Thanks @cfbolz for the PR, and @hauntsaninja for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…f functools.partial (pythonGH-127537) (cherry picked from commit 401bba6) Co-authored-by: CF Bolz-Tereick <[email protected]>
GH-128281 is a backport of this pull request to the 3.13 branch. |
Sorry, @cfbolz and @hauntsaninja, I could not cleanly backport this to
|
GH-128282 is a backport of this pull request to the 3.12 branch. |
…f functools.partial (python#127537) (cherry picked from commit 401bba6)
…f functools.partial (python#127537)
The Python version of
functools.partial
is missing the__class_getitem__
that would make it usable as a generic alias. This never matters for CPython, because it always uses the C-implementation of that class. However, in PyPy we always use the Python version.The problem went unnoticed because the tests for this behaviour got added to
test_genericalias.py
, which is only testing the C version (unliketest_functools.py
).