Merge "Python3: replace 'unicode' with 'six.text_type'"

This commit is contained in:
Jenkins 2015-06-12 20:59:34 +00:00 committed by Gerrit Code Review
commit 3e57e83c6f
7 changed files with 21 additions and 10 deletions

View File

@ -20,6 +20,7 @@ from neutronclient.v2_0 import client
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging
import six
import six.moves.urllib.parse as urlparse
import webob
@ -116,7 +117,8 @@ class MetadataProxyHandler(object):
LOG.exception(_LE("Unexpected error."))
msg = _('An unknown error has occurred. '
'Please try your request again.')
return webob.exc.HTTPInternalServerError(explanation=unicode(msg))
explanation = six.text_type(msg)
return webob.exc.HTTPInternalServerError(explanation=explanation)
def _get_ports_from_server(self, router_id=None, ip_address=None,
networks=None):
@ -257,7 +259,8 @@ class MetadataProxyHandler(object):
'Remote metadata server experienced an internal server error.'
)
LOG.warn(msg)
return webob.exc.HTTPInternalServerError(explanation=unicode(msg))
explanation = six.text_type(msg)
return webob.exc.HTTPInternalServerError(explanation=explanation)
else:
raise Exception(_('Unexpected response code: %s') % resp.status)

View File

@ -15,6 +15,7 @@
import httplib2
from oslo_config import cfg
from oslo_log import log as logging
import six
import six.moves.urllib.parse as urlparse
import webob
@ -56,7 +57,8 @@ class NetworkMetadataProxyHandler(object):
LOG.exception(_LE("Unexpected error."))
msg = _('An unknown error has occurred. '
'Please try your request again.')
return webob.exc.HTTPInternalServerError(explanation=unicode(msg))
explanation = six.text_type(msg)
return webob.exc.HTTPInternalServerError(explanation=explanation)
def _proxy_request(self, remote_address, method, path_info,
query_string, body):
@ -103,7 +105,8 @@ class NetworkMetadataProxyHandler(object):
'Remote metadata server experienced an internal server error.'
)
LOG.debug(msg)
return webob.exc.HTTPInternalServerError(explanation=unicode(msg))
explanation = six.text_type(msg)
return webob.exc.HTTPInternalServerError(explanation=explanation)
else:
raise Exception(_('Unexpected response code: %s') % resp.status)

View File

@ -506,7 +506,8 @@ class ExtensionManager(object):
LOG.debug('Ext namespace: %s', extension.get_namespace())
LOG.debug('Ext updated: %s', extension.get_updated())
except AttributeError as ex:
LOG.exception(_LE("Exception loading extension: %s"), unicode(ex))
LOG.exception(_LE("Exception loading extension: %s"),
six.text_type(ex))
return False
return True

View File

@ -18,6 +18,7 @@ Neutron base exception handling.
"""
from oslo_utils import excutils
import six
class NeutronException(Exception):
@ -40,6 +41,7 @@ class NeutronException(Exception):
# at least get the core message out if something happened
super(NeutronException, self).__init__(self.message)
if six.PY2:
def __unicode__(self):
return unicode(self.msg)

View File

@ -268,7 +268,7 @@ class OwnerCheck(policy.Check):
f)
match = self.match % target
if self.kind in creds:
return match == unicode(creds[self.kind])
return match == six.text_type(creds[self.kind])
return False

View File

@ -929,7 +929,9 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
return_value.update(initial_input['port'])
instance = self.plugin.return_value
instance.get_network.return_value = {'tenant_id': unicode(tenant_id)}
instance.get_network.return_value = {
'tenant_id': six.text_type(tenant_id)
}
instance.get_ports_count.return_value = 1
instance.create_port.return_value = return_value
res = self.api.post(_get_path('ports', fmt=self.fmt),

View File

@ -422,7 +422,7 @@ class JSONDictSerializer(DictSerializer):
def default(self, data):
def sanitizer(obj):
return unicode(obj)
return six.text_type(obj)
return jsonutils.dumps(data, default=sanitizer)