From 83326bf44c590a3b22ddf9bf658f509d1491bc0f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 29 Jul 2014 14:06:43 -0400 Subject: - The exception wrapping system for DBAPI errors can now accommodate non-standard DBAPI exceptions, such as the psycopg2 TransactionRollbackError. These exceptions will now be raised using the closest available subclass in ``sqlalchemy.exc``, in the case of TransactionRollbackError, ``sqlalchemy.exc.OperationalError``. fixes #3075 --- lib/sqlalchemy/exc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index 7d333fc01..a82bae33f 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -294,9 +294,12 @@ class DBAPIError(StatementError): statement, params, orig ) - name, glob = orig.__class__.__name__, globals() - if name in glob and issubclass(glob[name], DBAPIError): - cls = glob[name] + glob = globals() + for super_ in orig.__class__.__mro__: + name = super_.__name__ + if name in glob and issubclass(glob[name], DBAPIError): + cls = glob[name] + break return cls(statement, params, orig, connection_invalidated) -- cgit v1.2.1