From: Mike Bayer Date: Sun, 18 Oct 2009 04:05:47 +0000 (+0000) Subject: gratuitous try/except/else usage X-Git-Tag: rel_0_6beta1~246 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f9ee311cd8b66ec738095e2f176d81aea88b281;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git gratuitous try/except/else usage --- diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index efbc15d7f6..dfc415d2a9 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -1200,10 +1200,11 @@ class _ClassInstrumentationAdapter(ClassManager): def has_state(self, instance): try: state = self._get_state(instance) - return True except exc.NO_STATE: return False - + else: + return True + def state_getter(self): return self._get_state diff --git a/lib/sqlalchemy/orm/identity.py b/lib/sqlalchemy/orm/identity.py index c668bc5fea..4c1618df9b 100644 --- a/lib/sqlalchemy/orm/identity.py +++ b/lib/sqlalchemy/orm/identity.py @@ -102,7 +102,8 @@ class WeakInstanceDict(IdentityMap): return False except KeyError: return False - return o is not None + else: + return o is not None def contains_state(self, state): return dict.get(self, state.key) is state