diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-01-27 14:49:40 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-01-27 14:49:40 -0500 |
| commit | 516a442f233d90eb7b8bb844e2dea7865bb21f66 (patch) | |
| tree | bee884a5946bd240864a2e935185e3da16f887af /lib | |
| parent | 49dfeda6d7578aeae9ec954945cda38ee5aae6a9 (diff) | |
| download | sqlalchemy-516a442f233d90eb7b8bb844e2dea7865bb21f66.tar.gz | |
- reinstate "dont set up integer index in keymap if we're on cexts",
and this time also fix the cext itself to properly handle int vs. long
on py2k
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/cextension/resultproxy.c | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/result.py | 15 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c index 9c4d0c7e4..a87fe7b56 100644 --- a/lib/sqlalchemy/cextension/resultproxy.c +++ b/lib/sqlalchemy/cextension/resultproxy.c @@ -263,7 +263,7 @@ BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key) #if PY_MAJOR_VERSION < 3 if (PyInt_CheckExact(key)) { index = PyInt_AS_LONG(key); - } + } else #endif if (PyLong_CheckExact(key)) { diff --git a/lib/sqlalchemy/engine/result.py b/lib/sqlalchemy/engine/result.py index cc4ac74cd..39f4fc50c 100644 --- a/lib/sqlalchemy/engine/result.py +++ b/lib/sqlalchemy/engine/result.py @@ -35,7 +35,10 @@ except ImportError: try: from sqlalchemy.cresultproxy import BaseRowProxy + _baserowproxy_usecext = True except ImportError: + _baserowproxy_usecext = False + class BaseRowProxy(object): __slots__ = ('_parent', '_row', '_processors', '_keymap') @@ -210,11 +213,13 @@ class ResultMetaData(object): context, cursor_description, result_columns, num_ctx_cols, cols_are_ordered, textual_ordered) - # keymap indexes by integer index... - self._keymap = dict([ - (elem[0], (elem[3], elem[4], elem[0])) - for elem in raw - ]) + self._keymap = {} + if not _baserowproxy_usecext: + # keymap indexes by integer index... + self._keymap.update([ + (elem[0], (elem[3], elem[4], elem[0])) + for elem in raw + ]) # processors in key order for certain per-row # views like __iter__ and slices |
