diff options
Diffstat (limited to 'Lib/profile.py')
-rwxr-xr-x | Lib/profile.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/profile.py b/Lib/profile.py index 0340a79..c26f0c8 100755 --- a/Lib/profile.py +++ b/Lib/profile.py @@ -425,7 +425,19 @@ class Profile: 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 + else: + raise TypeError('runcall expected at least 1 positional argument, ' + 'got %d' % (len(args)-1)) + self.set_cmd(repr(func)) sys.setprofile(self.dispatcher) try: |