diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-07-15 19:11:36 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-07-15 19:11:36 (GMT) |
commit | ced770da07f9dbd7cc3afd09c2488c60faefe73c (patch) | |
tree | 6f1d9e1e50dabdcbd5ca7d38bdd0396ca60989bb /Lib/timeit.py | |
parent | 76d508b5d4bc8d69433956d6ee6309bbc31f3cf7 (diff) | |
download | cpython-ced770da07f9dbd7cc3afd09c2488c60faefe73c.zip cpython-ced770da07f9dbd7cc3afd09c2488c60faefe73c.tar.gz cpython-ced770da07f9dbd7cc3afd09c2488c60faefe73c.tar.bz2 |
Issue #24631: Fixed regression in the timeit modulu with multyline setup.
Diffstat (limited to 'Lib/timeit.py')
-rwxr-xr-x | Lib/timeit.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/timeit.py b/Lib/timeit.py index d9f9563..2de88f7 100755 --- a/Lib/timeit.py +++ b/Lib/timeit.py @@ -109,19 +109,18 @@ class Timer: if isinstance(setup, str): # Check that the code can be compiled outside a function compile(setup, dummy_src_name, "exec") + stmtprefix = setup + '\n' setup = reindent(setup, 4) elif callable(setup): local_ns['_setup'] = setup init += ', _setup=_setup' + stmtprefix = '' setup = '_setup()' else: raise ValueError("setup is neither a string nor callable") if isinstance(stmt, str): # Check that the code can be compiled outside a function - if isinstance(setup, str): - compile(setup + '\n' + stmt, dummy_src_name, "exec") - else: - compile(stmt, dummy_src_name, "exec") + compile(stmtprefix + stmt, dummy_src_name, "exec") stmt = reindent(stmt, 8) elif callable(stmt): local_ns['_stmt'] = stmt |