mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
[3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)
Turn deprecation warnings added in 3.8 into TypeError.
This commit is contained in:
parent
6c01ebcc0d
commit
142566c028
30 changed files with 45 additions and 330 deletions
|
@ -103,28 +103,12 @@ class Profile(_lsprof.Profiler):
|
|||
return self
|
||||
|
||||
# This method is more useful to profile a single function call.
|
||||
def runcall(*args, **kw):
|
||||
if len(args) >= 2:
|
||||
self, func, *args = args
|
||||
elif not args:
|
||||
raise TypeError("descriptor 'runcall' of 'Profile' object "
|
||||
"needs an argument")
|
||||
elif 'func' in kw:
|
||||
func = kw.pop('func')
|
||||
self, *args = args
|
||||
import warnings
|
||||
warnings.warn("Passing 'func' as keyword argument is deprecated",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
else:
|
||||
raise TypeError('runcall expected at least 1 positional argument, '
|
||||
'got %d' % (len(args)-1))
|
||||
|
||||
def runcall(self, func, /, *args, **kw):
|
||||
self.enable()
|
||||
try:
|
||||
return func(*args, **kw)
|
||||
finally:
|
||||
self.disable()
|
||||
runcall.__text_signature__ = '($self, func, /, *args, **kw)'
|
||||
|
||||
def __enter__(self):
|
||||
self.enable()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue