From: Mike Bayer Date: Wed, 27 Jan 2016 19:49:40 +0000 (-0500) Subject: - reinstate "dont set up integer index in keymap if we're on cexts", X-Git-Tag: rel_1_1_0b1~81^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=516a442f233d90eb7b8bb844e2dea7865bb21f66;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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 --- diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c index 9c4d0c7e49..a87fe7b565 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 cc4ac74cd5..39f4fc50c9 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