diff options
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 30964a6..64d1201 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -273,15 +273,9 @@ class partial: __slots__ = "func", "args", "keywords", "__dict__", "__weakref__" - def __new__(*args, **keywords): - if not args: - raise TypeError("descriptor '__new__' of partial needs an argument") - if len(args) < 2: - raise TypeError("type 'partial' takes at least one argument") - cls, func, *args = args + def __new__(cls, func, /, *args, **keywords): if not callable(func): raise TypeError("the first argument must be callable") - args = tuple(args) if hasattr(func, "func"): args = func.args + args @@ -295,10 +289,7 @@ class partial: self.keywords = keywords return self - def __call__(*args, **keywords): - if not args: - raise TypeError("descriptor '__call__' of partial needs an argument") - self, *args = args + def __call__(self, /, *args, **keywords): keywords = {**self.keywords, **keywords} return self.func(*self.args, *args, **keywords) @@ -402,8 +393,7 @@ class partialmethod(object): keywords=keywords) def _make_unbound_method(self): - def _method(*args, **keywords): - cls_or_self, *args = args + def _method(cls_or_self, /, *args, **keywords): keywords = {**self.keywords, **keywords} return self.func(cls_or_self, *self.args, *args, **keywords) _method.__isabstractmethod__ = self.__isabstractmethod__ |