Skip to content

Commit 1e61429

Browse files
committed
Rewrite to a try-except
1 parent e238e6a commit 1e61429

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/functools.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,12 @@ def _get_dispatch_param(func, *, _dispatchmethod=False):
910910
pass
911911
# Fallback path for more nuanced inspection of ambiguous callables.
912912
import inspect
913-
match list(inspect.signature(func).parameters.values())[idx:]:
914-
case [param] if param.kind < 3: # (*, param) or (**param)
913+
try:
914+
param = list(inspect.signature(func).parameters.values())[idx]
915+
if param.kind < 3: # (*, param) or (**param)
915916
return param.name
917+
except IndexError:
918+
pass
916919
return None
917920

918921
def singledispatch(func):

0 commit comments

Comments
 (0)