Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More meaningful variable names
  • Loading branch information
johnslavik committed Feb 16, 2026
commit e3538f57f9ae03ef2f4aea4ffb29e922d315c974
12 changes: 6 additions & 6 deletions Lib/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ def __init__(self, unbound, obj, cls):

# Dispatch on the second argument if a generic method turns into
# a bound method on instance-level access. See GH-143535.
self._skip_bound_arg = obj is None and isinstance(func, FunctionType)
self._skip_first_arg = obj is None and isinstance(func, FunctionType)

try:
self.__module__ = func.__module__
Expand Down Expand Up @@ -1093,22 +1093,22 @@ def __call__(self, /, *args, **kwargs):
'singledispatchmethod method')
raise TypeError(f'{funcname} requires at least '
'1 positional argument')
index = 1 if self._skip_bound_arg else 0
index = 1 if self._skip_first_arg else 0
method = self._dispatch(args[index].__class__)

if hasattr(method, "__get__"):
# If the method is a descriptor, it might be necessary
# to drop the first argument before calling
# as it can be no longer expected after descriptor access.
skip_first_arg = False
skip_bound_arg = False
if isinstance(method, staticmethod):
skip_first_arg = self._skip_bound_arg
skip_bound_arg = self._skip_first_arg

method = method.__get__(self._obj, self._cls)
if isinstance(method, MethodType):
skip_first_arg = self._skip_bound_arg
skip_bound_arg = self._skip_first_arg

if skip_first_arg:
if skip_bound_arg:
return method(*args[1:], **kwargs)
return method(*args, **kwargs)

Expand Down
Loading