Skip to content

Commit dc94cba

Browse files
committed
_dispatch
1 parent 20616d9 commit dc94cba

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Lib/functools.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -887,13 +887,14 @@ def singledispatch(func):
887887
dispatch_cache = weakref.WeakKeyDictionary()
888888
cache_token = None
889889

890-
def dispatch(cls):
890+
def dispatch(cls_obj):
891891
"""generic_func.dispatch(cls) -> <function implementation>
892892
893893
Runs the dispatch algorithm to return the best available implementation
894894
for the given *cls* registered on *generic_func*.
895895
896896
"""
897+
cls = cls_obj.__class__
897898
nonlocal cache_token
898899
if cache_token is not None:
899900
current_token = get_cache_token()
@@ -981,7 +982,7 @@ def wrapper(*args, **kw):
981982
if not args:
982983
raise TypeError(f'{funcname} requires at least '
983984
'1 positional argument')
984-
return dispatch(args[0].__class__)(*args, **kw)
985+
return dispatch(args[0])(*args, **kw)
985986

986987
funcname = getattr(func, '__name__', 'singledispatch function')
987988
registry[object] = func
@@ -1069,7 +1070,7 @@ def __call__(self, /, *args, **kwargs):
10691070
'singledispatchmethod method')
10701071
raise TypeError(f'{funcname} requires at least '
10711072
'1 positional argument')
1072-
return self._dispatch(args[0].__class__).__get__(self._obj, self._cls)(*args, **kwargs)
1073+
return self._dispatch(args[0]).__get__(self._obj, self._cls)(*args, **kwargs)
10731074

10741075
def __getattr__(self, name):
10751076
# Resolve these attributes lazily to speed up creation of

0 commit comments

Comments
 (0)