From cf0836b24d3ca90d6b5913deaf464407c14dbb4e 2012-05-27 09:51:49 From: Thomas Kluyver Date: 2012-05-27 09:51:49 Subject: [PATCH] timeit.template uses new-style string formatting from Python 3.3 --- diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index 3dab02b..177403f 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -774,7 +774,12 @@ python-profiler package from non-free.""") setup = timeit.reindent(stmt, 4) stmt = timeit.reindent(cell, 8) - src = timeit.template % dict(stmt=stmt, setup=setup) + # From Python 3.3, this template uses new-style string formatting. + if sys.version_info >= (3, 3): + src = timeit.template.format(stmt=stmt, setup=setup) + else: + src = timeit.template % dict(stmt=stmt, setup=setup) + # Track compilation time so it can be reported if too long # Minimum time above which compilation time will be reported tc_min = 0.1