From 1e29a74bd62c6c872819388e430901c35f84f07c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 18 Nov 2012 10:38:02 -0500 Subject: Fixed a gotcha where inadvertently calling list() on a :class:`.ColumnElement` would go into an endless loop, if :meth:`.ColumnOperators.__getitem__` were implemented. A new NotImplementedError is emitted via ``__iter__()``. --- lib/sqlalchemy/sql/operators.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/sqlalchemy/sql/operators.py') diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index 88f56e5ec..7513c0b82 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -310,6 +310,11 @@ class ColumnOperators(Operators): """ return self.operate(neg) + def __iter__(self): + """Block calls to list() from calling __getitem__() endlessly.""" + + raise NotImplementedError("Class %s is not iterable" % self.__class__) + def __getitem__(self, index): """Implement the [] operator. -- cgit v1.2.1