]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Folds identical exception wrappers into single by combining types into a tuple. 5325/head
authorElmer de Looff <elmer.delooff@gmail.com>
Thu, 14 May 2020 21:17:07 +0000 (23:17 +0200)
committerElmer de Looff <elmer.delooff@gmail.com>
Thu, 14 May 2020 21:17:07 +0000 (23:17 +0200)
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/exc.py

index 4d308d26b3d4fbd7d944cff70b081a27da5fc391..4f86608d94bc913ba49f786e5ab79f8c88e3ec21 100644 (file)
@@ -313,11 +313,7 @@ def object_state(instance):
 def _inspect_mapped_object(instance):
     try:
         return instance_state(instance)
-        # TODO: whats the py-2/3 syntax to catch two
-        # different kinds of exceptions at once ?
-    except exc.UnmappedClassError:
-        return None
-    except exc.NO_STATE:
+    except (exc.UnmappedClassError,) + exc.NO_STATE:
         return None
 
 
index f061a6a56deb825ad11d557bc3416e873e635c77..f5d04c2fc53abbc7c82d57169f9fea8f84f77869 100644 (file)
@@ -196,9 +196,7 @@ def _safe_cls_name(cls):
 def _default_unmapped(base, cls):
     try:
         mappers = base.manager_of_class(cls).mappers
-    except NO_STATE:
-        mappers = {}
-    except TypeError:
+    except (TypeError,) + NO_STATE:
         mappers = {}
     name = _safe_cls_name(cls)