diff options
Diffstat (limited to 'Lib/trace.py')
-rwxr-xr-x | Lib/trace.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/trace.py b/Lib/trace.py index 3049e4ec683..fd40fbae850 100755 --- a/Lib/trace.py +++ b/Lib/trace.py @@ -451,7 +451,22 @@ class Trace: sys.settrace(None) threading.settrace(None) - def runfunc(self, func, *args, **kw): + def runfunc(*args, **kw): + if len(args) >= 2: + self, func, *args = args + elif not args: + raise TypeError("descriptor 'runfunc' of 'Trace' 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('runfunc expected at least 1 positional argument, ' + 'got %d' % (len(args)-1)) + result = None if not self.donothing: sys.settrace(self.globaltrace) |