diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-07-15 22:12:33 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-07-15 22:12:33 +0300 |
commit | 3a2290865972e47d68360af4fed6ad9ef4b4434c (patch) | |
tree | a72ae3ae80adcfb5f4997517c53108afe3c0c467 /Lib/timeit.py | |
parent | a7282c0ff7aff5ed00c0355e60fcbd34c45af910 (diff) | |
parent | ced770da07f9dbd7cc3afd09c2488c60faefe73c (diff) | |
download | cpython-git-3a2290865972e47d68360af4fed6ad9ef4b4434c.tar.gz |
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 d9f9563c2e..2de88f7271 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 |