]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use six.reraise() for Python 3 compatibility
authorVictor Stinner <vstinner@redhat.com>
Wed, 10 Jun 2015 12:49:59 +0000 (14:49 +0200)
committerVictor Stinner <vstinner@redhat.com>
Thu, 11 Jun 2015 14:09:48 +0000 (16:09 +0200)
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

cinder/exception.py
cinder/image/glance.py
cinder/volume/drivers/netapp/dataontap/block_base.py
cinder/volume/drivers/netapp/dataontap/client/client_base.py

index 5f4a9f5ca0cc3af4e4e4de1aad57d5668231fe61..adcebb8863d20f2a7d1ddb7ff62d3861709fa58c 100644 (file)
@@ -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):
index 42de65d77e34aa5fc792d4126457e39e077fd956..367e9966a1f323c988ed96a8dfe7e471a71a42fc 100644 (file)
@@ -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):
index 23e9eae7740ea1d873c9ffa4f0d0e3cc44a981ee..5a97b3424fa7d6af01394a6244c628dad1214e29 100644 (file)
@@ -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."""
index ce7a575e0649d7f66edcb821761dce403f41a525..98c57133a81adcf96a1d661aeafb94325d2639de 100644 (file)
@@ -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."""