From 5bb5e7a3503536c0439aa4e1948291648c2a0277 Mon Sep 17 00:00:00 2001 From: Dolph Mathews Date: Wed, 24 Oct 2012 10:13:54 -0500 Subject: Exception.message deprecated in py26 (bug 1070890) In the case of IntegrityError (e), e is wrapping a DBAPIError[1] with more information about the context of the exception -- context that we do NOT want to expose to our own API users (however, that context should still be logged). In the case of an integrity error, str(e.orig) will produce exactly what we're producing with e.message today: a user-friendly message such as 'column name is not unique' This change should not impact what is logged or returned to the API user -- just eliminate the deprecation warning. [1]: http://docs.sqlalchemy.org/en/rel_0_7/core/exceptions.html#sqlalchemy.exc.DBAPIError Change-Id: Ie3a5d93fbb5a7b90ad3b205bc8610f28b1626431 --- keystone/identity/backends/sql.py | 2 +- keystone/service.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/keystone/identity/backends/sql.py b/keystone/identity/backends/sql.py index 7a2abf59..69c6aab3 100644 --- a/keystone/identity/backends/sql.py +++ b/keystone/identity/backends/sql.py @@ -41,7 +41,7 @@ def handle_conflicts(type='object'): try: return method(*args, **kwargs) except sql.IntegrityError as e: - raise exception.Conflict(type=type, details=e.message) + raise exception.Conflict(type=type, details=str(e.orig)) return wrapper return decorator diff --git a/keystone/service.py b/keystone/service.py index fdc895cb..c04cfba6 100644 --- a/keystone/service.py +++ b/keystone/service.py @@ -337,7 +337,7 @@ class TokenController(wsgi.Application): LOG.warning('Tenant %s is disabled' % tenant_id) raise exception.Unauthorized() except AssertionError as e: - raise exception.Unauthorized(e.message) + raise exception.Unauthorized(str(e)) auth_token_data = dict(zip(['user', 'tenant', 'metadata'], auth_info)) expiry = self.token_api._get_default_expire_time(context=context) -- cgit