aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/cProfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/cProfile.py')
-rwxr-xr-xLib/cProfile.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py
index 305e79e2804..2e449cc576c 100755
--- a/Lib/cProfile.py
+++ b/Lib/cProfile.py
@@ -103,7 +103,22 @@ class Profile(_lsprof.Profiler):
return self
# This method is more useful to profile a single function call.
- def runcall(self, func, *args, **kw):
+ 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))
+
self.enable()
try:
return func(*args, **kw)