diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-01-04 17:54:39 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-01-04 17:54:39 +0000 |
| commit | 4b2a0ca7aef4a1af4a2cd26eaae3055e930f42b7 (patch) | |
| tree | 102c8f0e8c090440f540bee82d3b59b5bcc33479 /lib/sqlalchemy | |
| parent | 04b2203e28e75e3a20b3536beadf8eda0dfa117b (diff) | |
| parent | a54a0c6ec7aae89003cbb47c79a1850248f57a29 (diff) | |
| download | sqlalchemy-4b2a0ca7aef4a1af4a2cd26eaae3055e930f42b7.tar.gz | |
Merge "Fix cext for Python 2; ensure C extensions build successfully"
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 |
