]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
gratuitous try/except/else usage
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 18 Oct 2009 04:05:47 +0000 (04:05 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 18 Oct 2009 04:05:47 +0000 (04:05 +0000)
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/identity.py

index efbc15d7f64f3fe16838b88c4b004c1b5830e697..dfc415d2a99759c0be4920e599d22d0c4f58958b 100644 (file)
@@ -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
 
index c668bc5fea9b3298bbf3d2c821565272f19842db..4c1618df9b7304082ea7efabbffa29a30513718a 100644 (file)
@@ -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