bpo-36743: __get__ is sometimes called without the owner argument (#12992)

This commit is contained in:
Raymond Hettinger 2019-08-29 01:27:42 -07:00 committed by GitHub
parent 84125fed2a
commit 0dac68f1e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 13 deletions

View file

@ -383,7 +383,7 @@ class partialmethod(object):
_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:
@ -888,7 +888,7 @@ class singledispatchmethod:
"""
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)
@ -926,7 +926,7 @@ class cached_property:
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: