diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2011-10-28 12:52:29 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2011-10-28 12:52:29 (GMT) |
commit | aabbda5354407cfe35097c7f17717a716a3d80c4 (patch) | |
tree | e15e7fe42975e08e567879ec8a949d4986ca4493 /Lib/timeit.py | |
parent | ac73b0c95e352563ecf0a4643b30215b9bdee1a5 (diff) | |
parent | 5d1155c08edf7f53eca804b2b6538636c2dfe711 (diff) | |
download | cpython-aabbda5354407cfe35097c7f17717a716a3d80c4.zip cpython-aabbda5354407cfe35097c7f17717a716a3d80c4.tar.gz cpython-aabbda5354407cfe35097c7f17717a716a3d80c4.tar.bz2 |
Merge 3.2
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 f45168b..fdc0bbb 100644 --- a/Lib/timeit.py +++ b/Lib/timeit.py @@ -127,7 +127,7 @@ class Timer: if isinstance(setup, str): setup = reindent(setup, 4) src = template.format(stmt=stmt, setup=setup) - elif hasattr(setup, '__call__'): + elif callable(setup): src = template.format(stmt=stmt, setup='_setup()') ns['_setup'] = setup else: @@ -136,13 +136,13 @@ class Timer: code = compile(src, dummy_src_name, "exec") exec(code, globals(), ns) self.inner = ns["inner"] - elif hasattr(stmt, '__call__'): + elif callable(stmt): self.src = None if isinstance(setup, str): _setup = setup def setup(): exec(_setup, globals(), ns) - elif not hasattr(setup, '__call__'): + elif not callable(setup): raise ValueError("setup is neither a string nor callable") self.inner = _template_func(setup, stmt) else: |