From: Victor Stinner Date: Wed, 10 Jun 2015 12:49:59 +0000 (+0200) Subject: Use six.reraise() for Python 3 compatibility X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=509e411af7513738752a62af37bbd31ccacec7ed;p=openstack-build%2Fcinder-build.git Use six.reraise() for Python 3 compatibility Replace "raise a, b, c" with "six.reraise(a, b, c)" to make the Cinder code compatible with Python 3. This patch was generated by the raise operation of the sixer tool: https://pypi.python.org/pypi/sixer Blueprint cinder-python3 Change-Id: Iab9e12763e2a7641fc2671acdd4f2ff84be584f3 --- diff --git a/cinder/exception.py b/cinder/exception.py index 5f4a9f5ca..adcebb886 100644 --- a/cinder/exception.py +++ b/cinder/exception.py @@ -97,7 +97,7 @@ class CinderException(Exception): LOG.error(_LE("%(name)s: %(value)s"), {'name': name, 'value': value}) if CONF.fatal_exception_format_errors: - raise exc_info[0], exc_info[1], exc_info[2] + six.reraise(*exc_info) # at least get the core message out if something happened message = self.message elif isinstance(message, Exception): diff --git a/cinder/image/glance.py b/cinder/image/glance.py index 42de65d77..367e9966a 100644 --- a/cinder/image/glance.py +++ b/cinder/image/glance.py @@ -31,6 +31,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils from oslo_utils import timeutils +import six from six.moves import urllib from cinder import exception @@ -480,14 +481,14 @@ def _reraise_translated_image_exception(image_id): """Transform the exception for the image but keep its traceback intact.""" _exc_type, exc_value, exc_trace = sys.exc_info() new_exc = _translate_image_exception(image_id, exc_value) - raise new_exc, None, exc_trace + six.reraise(new_exc, None, exc_trace) def _reraise_translated_exception(): """Transform the exception but keep its traceback intact.""" _exc_type, exc_value, exc_trace = sys.exc_info() new_exc = _translate_plain_exception(exc_value) - raise new_exc, None, exc_trace + six.reraise(new_exc, None, exc_trace) def _translate_image_exception(image_id, exc_value): diff --git a/cinder/volume/drivers/netapp/dataontap/block_base.py b/cinder/volume/drivers/netapp/dataontap/block_base.py index 23e9eae77..5a97b3424 100644 --- a/cinder/volume/drivers/netapp/dataontap/block_base.py +++ b/cinder/volume/drivers/netapp/dataontap/block_base.py @@ -341,7 +341,7 @@ class NetAppBlockStorageLibrary(object): if lun_id is not None: return lun_id else: - raise exc_info[0], exc_info[1], exc_info[2] + six.reraise(*exc_info) def _unmap_lun(self, path, initiator_list): """Unmaps a LUN from given initiator.""" diff --git a/cinder/volume/drivers/netapp/dataontap/client/client_base.py b/cinder/volume/drivers/netapp/dataontap/client/client_base.py index ce7a575e0..98c57133a 100644 --- a/cinder/volume/drivers/netapp/dataontap/client/client_base.py +++ b/cinder/volume/drivers/netapp/dataontap/client/client_base.py @@ -134,7 +134,7 @@ class Client(object): if e.code == '13115' or e.code == '9016': pass else: - raise exc_info[0], exc_info[1], exc_info[2] + six.reraise(*exc_info) def create_igroup(self, igroup, igroup_type='iscsi', os_type='default'): """Creates igroup with specified args."""