diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/cextension/resultproxy.c | 11 | ||||
-rw-r--r-- | lib/sqlalchemy/engine/base.py | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c index 325007c11..3494ccae6 100644 --- a/lib/sqlalchemy/cextension/resultproxy.c +++ b/lib/sqlalchemy/cextension/resultproxy.c @@ -353,7 +353,16 @@ BaseRowProxy_getattro(BaseRowProxy *self, PyObject *name) else return tmp; - return BaseRowProxy_subscript(self, name); + tmp = BaseRowProxy_subscript(self, name); + if (tmp == NULL && PyErr_ExceptionMatches(PyExc_KeyError)) { + PyErr_Format( + PyExc_AttributeError, + "Could not locate column in row for column '%.200s'", + PyString_AsString(name) + ); + return NULL; + } + return tmp; } /*********************** diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 7cc5522c4..d16fc9c68 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -2623,7 +2623,6 @@ except ImportError: def __getattr__(self, name): try: - # TODO: no test coverage here return self[name] except KeyError, e: raise AttributeError(e.args[0]) |