diff options
| author | Dirk Mueller <dirk@dmllr.de> | 2013-04-22 03:42:48 +0200 |
|---|---|---|
| committer | Dirk Mueller <dirk@dmllr.de> | 2013-04-22 03:42:48 +0200 |
| commit | 120ddeff7e1b8956fe35a7a39fae87ddcac8301c (patch) | |
| tree | b4eb9b278beca16004e6b1825d8173783390540a /openstack/common/db/sqlalchemy | |
| parent | 67767b3e8074e4b4a218d7649ef2297c124c342f (diff) | |
| download | oslo-120ddeff7e1b8956fe35a7a39fae87ddcac8301c.tar.gz oslo-120ddeff7e1b8956fe35a7a39fae87ddcac8301c.tar.xz oslo-120ddeff7e1b8956fe35a7a39fae87ddcac8301c.zip | |
Improve Python 3.x compatibility
Mechanical translation of deprecated constructs
to 3.x compatible variants.
Change-Id: I4988d0ac656903e0d0320aaa8361d4eeb774a0f9
Diffstat (limited to 'openstack/common/db/sqlalchemy')
| -rw-r--r-- | openstack/common/db/sqlalchemy/session.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/openstack/common/db/sqlalchemy/session.py b/openstack/common/db/sqlalchemy/session.py index 77a1dc8..c719063 100644 --- a/openstack/common/db/sqlalchemy/session.py +++ b/openstack/common/db/sqlalchemy/session.py @@ -419,12 +419,12 @@ def _wrap_db_error(f): # note(boris-42): We should catch unique constraint violation and # wrap it by our own DBDuplicateEntry exception. Unique constraint # violation is wrapped by IntegrityError. - except sqla_exc.OperationalError, e: + except sqla_exc.OperationalError as e: _raise_if_deadlock_error(e, get_engine().name) # NOTE(comstud): A lot of code is checking for OperationalError # so let's not wrap it for now. raise - except sqla_exc.IntegrityError, e: + except sqla_exc.IntegrityError as e: # note(boris-42): SqlAlchemy doesn't unify errors from different # DBs so we must do this. Also in some tables (for example # instance_types) there are more than one unique constraint. This @@ -432,7 +432,7 @@ def _wrap_db_error(f): # unique constraint, from error message. _raise_if_duplicate_entry_error(e, get_engine().name) raise exception.DBError(e) - except Exception, e: + except Exception as e: LOG.exception(_('DB exception wrapped.')) raise exception.DBError(e) _wrap.func_name = f.func_name @@ -481,7 +481,7 @@ def _ping_listener(dbapi_conn, connection_rec, connection_proxy): """ try: dbapi_conn.cursor().execute('select 1') - except dbapi_conn.OperationalError, ex: + except dbapi_conn.OperationalError as ex: if ex.args[0] in (2006, 2013, 2014, 2045, 2055): LOG.warn(_('Got mysql server has gone away: %s'), ex) raise sqla_exc.DisconnectionError("Database server went away") @@ -545,7 +545,7 @@ def create_engine(sql_connection): try: engine.connect() - except sqla_exc.OperationalError, e: + except sqla_exc.OperationalError as e: if not _is_db_connection_error(e.args[0]): raise @@ -561,7 +561,7 @@ def create_engine(sql_connection): try: engine.connect() break - except sqla_exc.OperationalError, e: + except sqla_exc.OperationalError as e: if (remaining != 'infinite' and remaining == 0) or \ not _is_db_connection_error(e.args[0]): raise |
