mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140873: Add support of non-descriptor callables in functools.singledispatchmethod() (GH-140884)
This commit is contained in:
parent
b99db92dde
commit
b2b68d40f8
5 changed files with 52 additions and 3 deletions
|
|
@ -1083,7 +1083,10 @@ def __call__(self, /, *args, **kwargs):
|
|||
'singledispatchmethod method')
|
||||
raise TypeError(f'{funcname} requires at least '
|
||||
'1 positional argument')
|
||||
return self._dispatch(args[0].__class__).__get__(self._obj, self._cls)(*args, **kwargs)
|
||||
method = self._dispatch(args[0].__class__)
|
||||
if hasattr(method, "__get__"):
|
||||
method = method.__get__(self._obj, self._cls)
|
||||
return method(*args, **kwargs)
|
||||
|
||||
def __getattr__(self, name):
|
||||
# Resolve these attributes lazily to speed up creation of
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue