From a54a0c6ec7aae89003cbb47c79a1850248f57a29 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 3 Jan 2020 12:10:57 -0500 Subject: Fix cext for Python 2; ensure C extensions build successfully The C extensions have been broken since cc718cccc0bf8a01abdf4068c however CI did not find this, because the build degraded to non-C extensions without failing. Ensure that if cext is set, there is no fallback to non-cext build if the C extension build fails. Repair C related issues introduced in cc718cccc0bf8a01abdf4068c. As C extensions have been silently failing on 2.7 for some commits, the callcounts also needed to be adjusted for recent performance-related changes. That in turn required a fix to the profiling decorator to use signature rewriting in order to support py.test's fixture mechanism under Python 2, usage introduced under profiling in 89bf6d80a9. Fixes: #5076 Change-Id: Id968f10c85d6bf489298b1c318a1f869ad3e7d80 --- lib/sqlalchemy/testing/profiling.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'lib/sqlalchemy/testing/profiling.py') diff --git a/lib/sqlalchemy/testing/profiling.py b/lib/sqlalchemy/testing/profiling.py index fdf983a8f..14a6fc4ac 100644 --- a/lib/sqlalchemy/testing/profiling.py +++ b/lib/sqlalchemy/testing/profiling.py @@ -22,7 +22,6 @@ from . import config from .util import gc_collect from ..util import jython from ..util import pypy -from ..util import update_wrapper from ..util import win32 @@ -232,17 +231,21 @@ def function_call_count(variance=0.05, times=1): """ - def decorate(fn): - def wrap(*args, **kw): - timerange = range(times) - with count_functions(variance=variance): - for time in timerange: - rv = fn(*args, **kw) - return rv + # use signature-rewriting decorator function so that py.test fixtures + # still work on py27. In Py3, update_wrapper() alone is good enough, + # likely due to the introduction of __signature__. - return update_wrapper(wrap, fn) + from sqlalchemy.util import decorator - return decorate + @decorator + def wrap(fn, *args, **kw): + timerange = range(times) + with count_functions(variance=variance): + for time in timerange: + rv = fn(*args, **kw) + return rv + + return wrap @contextlib.contextmanager -- cgit v1.2.1