bpo-36743: __get__ is sometimes called without the owner argument (GH-12992) (GH-15589)
(cherry picked from commit 0dac68f1e593c11612ed54af9edb865d398f3b05)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
diff --git a/Lib/functools.py b/Lib/functools.py
index 64d1201..a674a68 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -400,7 +400,7 @@
_method._partialmethod = self
return _method
- def __get__(self, obj, cls):
+ def __get__(self, obj, cls=None):
get = getattr(self.func, "__get__", None)
result = None
if get is not None:
@@ -905,7 +905,7 @@
"""
return self.dispatcher.register(cls, func=method)
- def __get__(self, obj, cls):
+ def __get__(self, obj, cls=None):
def _method(*args, **kwargs):
method = self.dispatcher.dispatch(args[0].__class__)
return method.__get__(obj, cls)(*args, **kwargs)
@@ -943,7 +943,7 @@
f"({self.attrname!r} and {name!r})."
)
- def __get__(self, instance, owner):
+ def __get__(self, instance, owner=None):
if instance is None:
return self
if self.attrname is None: