diff options
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/cextension/resultproxy.c | 16 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/profiling.py | 23 |
2 files changed, 28 insertions, 11 deletions
diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c index 691fd9c48..f6523359d 100644 --- a/lib/sqlalchemy/cextension/resultproxy.c +++ b/lib/sqlalchemy/cextension/resultproxy.c @@ -21,6 +21,20 @@ typedef Py_ssize_t (*lenfunc)(PyObject *); typedef intargfunc ssizeargfunc; #endif +#if PY_MAJOR_VERSON < 3 + +// new typedef in Python 3 +typedef long Py_hash_t; + +// from pymacro.h, new in Python 3.2 +#if defined(__GNUC__) || defined(__clang__) +# define Py_UNUSED(name) _unused_ ## name __attribute__((unused)) +#else +# define Py_UNUSED(name) _unused_ ## name +#endif + +#endif + /*********** * Structs * @@ -868,7 +882,7 @@ initcresultproxy(void) INITERROR; if (PyType_Ready(&tuplegetter_type) < 0) - return NULL; + INITERROR; #if PY_MAJOR_VERSION >= 3 m = PyModule_Create(&module_def); 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 |