From: Philip Jenvey Date: Tue, 21 Jul 2009 05:26:26 +0000 (+0000) Subject: refactor to handle lazy loaded columns raising UnboundExecutionErrors. fixes X-Git-Tag: rel_0_6_6~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9aa8f3039f2216e4fa0e8f89e25c725d77bb48e9;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git refactor to handle lazy loaded columns raising UnboundExecutionErrors. fixes orm.test_merge test_no_load_with_backrefs on Jython, CPython avoided this due to the luck of dict ordering --- diff --git a/test/orm/_base.py b/test/orm/_base.py index 44bfd08a40..f08d253d57 100644 --- a/test/orm/_base.py +++ b/test/orm/_base.py @@ -2,6 +2,7 @@ import inspect import sys import types import sqlalchemy as sa +import sqlalchemy.exceptions as sa_exc from sqlalchemy.test import config, testing from sqlalchemy.test.testing import resolve_artifact_names, adict from sqlalchemy.test.engines import drop_all_tables @@ -74,20 +75,19 @@ class ComparableEntity(BasicEntity): if attr.startswith('_'): continue value = getattr(a, attr) - if (hasattr(value, '__iter__') and - not isinstance(value, basestring)): - try: - # catch AttributeError so that lazy loaders trigger - battr = getattr(b, attr) - except AttributeError: - return False + try: + # handle lazy loader errors + battr = getattr(b, attr) + except (AttributeError, sa_exc.UnboundExecutionError): + return False + + if hasattr(value, '__iter__'): if list(value) != list(battr): return False else: - if value is not None: - if value != getattr(b, attr, None): - return False + if value is not None and value != battr: + return False return True finally: _recursion_stack.remove(id(self))