From 39c5e1cecbac9709c6a8562cfe95f9afd9274b09 Mon Sep 17 00:00:00 2001 From: XinxinShen Date: Wed, 6 Jan 2021 14:49:46 +0800 Subject: [PATCH] remove six remove six in venus/exception.py remove six in requirements.txt Change-Id: If0401a01ccf2755a85fbc03ca31adb8a19962972 --- requirements.txt | 1 - venus/exception.py | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index 94edf55..c2d8609 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,6 @@ oslo.versionedobjects>=0.9.0 oslo.i18n>=1.5.0 # Apache-2.0 osprofiler>=0.3.0 # Apache-2.0 openstacksdk>=0.46.0 # Apache-2.0 -six>=1.9.0 SQLAlchemy>=1.2.19 # MIT sqlalchemy-migrate>=0.9.6 PyMySQL>=0.7.11 diff --git a/venus/exception.py b/venus/exception.py index 9fc1113..13ca96b 100644 --- a/venus/exception.py +++ b/venus/exception.py @@ -20,10 +20,8 @@ SHOULD include dedicated exception logging. """ -import sys from oslo_versionedobjects import exception as obj_exc -import six import webob.exc from venus.common.utils import LOG @@ -68,14 +66,13 @@ class VenusException(Exception): for k, v in self.kwargs.items(): if isinstance(v, Exception): - self.kwargs[k] = six.text_type(v) + self.kwargs[k] = str(v) if self._should_format(): try: message = self.message % kwargs - except Exception: - exc_info = sys.exc_info() + except Exception as e: # kwargs doesn't match a variable in the message # log the issue and the kwargs LOG.exception(_LE('Exception in string format operation')) @@ -83,11 +80,11 @@ class VenusException(Exception): LOG.error(_LE("%(name)s: %(value)s"), {'name': name, 'value': value}) if CONF.fatal_exception_format_errors: - six.reraise(*exc_info) + raise e # at least get the core message out if something happened message = self.message elif isinstance(message, Exception): - message = six.text_type(message) + message = str(message) # NOTE(luisg): We put the actual message in 'msg' so that we can access # it, because if we try to access the message via 'message' it will be @@ -99,7 +96,7 @@ class VenusException(Exception): return self.kwargs['message'] is None or '%(message)' in self.message def __unicode__(self): - return six.text_type(self.msg) + return str(self.msg) class NotAuthorized(VenusException):