[3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)
Turn deprecation warnings added in 3.8 into TypeError.
diff --git a/Lib/functools.py b/Lib/functools.py
index 64d1201..9495fbe 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -345,23 +345,7 @@
callables as instance methods.
"""
- def __init__(*args, **keywords):
- if len(args) >= 2:
- self, func, *args = args
- elif not args:
- raise TypeError("descriptor '__init__' of partialmethod "
- "needs an argument")
- elif 'func' in keywords:
- func = keywords.pop('func')
- self, *args = args
- import warnings
- warnings.warn("Passing 'func' as keyword argument is deprecated",
- DeprecationWarning, stacklevel=2)
- else:
- raise TypeError("type 'partialmethod' takes at least one argument, "
- "got %d" % (len(args)-1))
- args = tuple(args)
-
+ def __init__(self, func, /, *args, **keywords):
if not callable(func) and not hasattr(func, "__get__"):
raise TypeError("{!r} is not callable or a descriptor"
.format(func))
@@ -379,7 +363,6 @@
self.func = func
self.args = args
self.keywords = keywords
- __init__.__text_signature__ = '($self, func, /, *args, **keywords)'
def __repr__(self):
args = ", ".join(map(repr, self.args))