summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/cextension
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-03-30 17:05:30 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-03-30 17:05:30 -0400
commit4df1e07bb9c43ed8d1927a90c75f3142beaa403a (patch)
tree49e11f239390c653e2d2b60c743f37395584f004 /lib/sqlalchemy/cextension
parent4a3205df84b737f5fe55914fe22eef7264f20764 (diff)
parentf84ef1f83cc64a5ea3a910b8d1bdf00b05e9ceab (diff)
downloadsqlalchemy-4df1e07bb9c43ed8d1927a90c75f3142beaa403a.tar.gz
Merge remote-tracking branch 'origin/pr/231' into pr231
Diffstat (limited to 'lib/sqlalchemy/cextension')
-rw-r--r--lib/sqlalchemy/cextension/resultproxy.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c
index f5593f60d..170278cff 100644
--- a/lib/sqlalchemy/cextension/resultproxy.c
+++ b/lib/sqlalchemy/cextension/resultproxy.c
@@ -263,6 +263,8 @@ BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key)
#if PY_MAJOR_VERSION < 3
if (PyInt_CheckExact(key)) {
index = PyInt_AS_LONG(key);
+ if (index < 0)
+ index += BaseRowProxy_length(self);
} else
#endif
@@ -271,6 +273,8 @@ BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key)
if ((index == -1) && PyErr_Occurred())
/* -1 can be either the actual value, or an error flag. */
return NULL;
+ if (index < 0)
+ index += BaseRowProxy_length(self);
} else if (PySlice_Check(key)) {
values = PyObject_GetItem(self->row, key);
if (values == NULL)