mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Merge 3.2
This commit is contained in:
commit
aabbda5354
27 changed files with 51 additions and 54 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue