Skip to content

Commit d05750f

Browse files
committed
Cut first argument after the fact!
1 parent 1142577 commit d05750f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Lib/functools.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# import weakref # Deferred to single_dispatch()
2020
from operator import itemgetter
2121
from reprlib import recursive_repr
22-
from types import FunctionType, GenericAlias, MethodType, MappingProxyType, UnionType
22+
from types import GenericAlias, MethodType, MappingProxyType, UnionType
2323
from _thread import RLock
2424

2525
################################################################################
@@ -1096,12 +1096,15 @@ def __call__(self, /, *args, **kwargs):
10961096
'1 positional argument')
10971097
if self._skip_bound_arg:
10981098
method = self._dispatch(args[1].__class__)
1099-
if isinstance(method, FunctionType):
1100-
args = args[1:]
11011099
else:
11021100
method = self._dispatch(args[0].__class__)
11031101
if hasattr(method, "__get__"):
11041102
method = method.__get__(self._obj, self._cls)
1103+
if (
1104+
self._skip_bound_arg
1105+
and isinstance(method, MethodType)
1106+
and method.__self__ is self):
1107+
args = args[1:]
11051108
return method(*args, **kwargs)
11061109

11071110
def __getattr__(self, name):

0 commit comments

Comments
 (0)