diff options
Diffstat (limited to 'Lib/timeit.py')
-rw-r--r-- | Lib/timeit.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/timeit.py b/Lib/timeit.py index 9054243..052f140 100644 --- a/Lib/timeit.py +++ b/Lib/timeit.py @@ -126,7 +126,7 @@ class Timer: if isinstance(setup, basestring): setup = reindent(setup, 4) src = template % {'stmt': stmt, 'setup': setup} - elif callable(setup): + elif hasattr(setup, '__call__'): src = template % {'stmt': stmt, 'setup': '_setup()'} ns['_setup'] = setup else: @@ -135,13 +135,13 @@ class Timer: code = compile(src, dummy_src_name, "exec") exec code in globals(), ns self.inner = ns["inner"] - elif callable(stmt): + elif hasattr(stmt, '__call__'): self.src = None if isinstance(setup, basestring): _setup = setup def setup(): exec _setup in globals(), ns - elif not callable(setup): + elif not hasattr(setup, '__call__'): raise ValueError("setup is neither a string nor callable") self.inner = _template_func(setup, stmt) else: |