-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-121027: Make the functools.partial object a method descriptor #121089
Conversation
5ecccee
to
693fbc7
Compare
This should have been labeled as "DO-NOT-MERGE" until #121086 was merged. There are conflicts anyway now. |
Co-authored-by: d.grigonis <[email protected]>
693fbc7
to
d752505
Compare
@@ -402,7 +398,7 @@ def _method(cls_or_self, /, *args, **keywords): | |||
def __get__(self, obj, cls=None): | |||
get = getattr(self.func, "__get__", None) | |||
result = None | |||
if get is not None and not isinstance(self.func, partial): | |||
if get is not None: |
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.
It was needed to avoid emitting a warning for partialmethod(partial(...))
, even if the final behavior is not changed.
|
pythonGH-121089) Co-authored-by: d.grigonis <[email protected]>
pythonGH-121089) Co-authored-by: d.grigonis <[email protected]>
PR #121089 added an eager import for types.MethodType, but still left the existing hacks for lazily importing from types. We could also create MethodType internally in functools.py (e.g., by using `type(Placeholder.__repr__)`, but it feels not worth it at this point, so instead I unlazified all the usages of types in the module.
May I ask why this change was considered critical enough to not follow PEP 387? It is clearly backwards incompatible and is in fact breaking code, see lark-parser/lark#1480 . |
Co-authored-by: d.grigonis [email protected]
📚 Documentation preview 📚: https://cpython-previews--121089.org.readthedocs.build/