Merge lp:~tpatil/nova/bug709510 into lp:~hudson-openstack/nova/trunk

Proposed by Tushar Patil
Status: Merged
Approved by: Vish Ishaya
Approved revision: 643
Merged at revision: 643
Proposed branch: lp:~tpatil/nova/bug709510
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 65 lines (+12/-11)
2 files modified
nova/api/ec2/__init__.py (+10/-9)
nova/api/openstack/__init__.py (+2/-2)
To merge this branch: bzr merge lp:~tpatil/nova/bug709510
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Thierry Carrez (community) gfe Approve
Devin Carlen (community) Approve
Review via email: mp+48078@code.launchpad.net

Commit message

Fix for LP Bug #709510

Description of the change

coerce the exceptions to unicode.

This will work in python 2.x but will fail in python 3.x because unicode function is not supported in 3.x. By default all string are unicode string. When python 3.x will be supported bby nova at that time we will need to port and replace from unicode() to str() again.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

Seems like this is getting changed back and forth from ex.args[0] to ex. Do we have any kind of consensus here?

review: Needs Information
Revision history for this message
Tushar Patil (tpatil) wrote :

When LP Bug #699654 was fixed at that time itself it should have fixed/reviewed in the right manner. But that didn't happen.

Thanks to Vishy for pointing out the correct way of fixing this problem.

Revision history for this message
Devin Carlen (devcamcar) wrote :

Good and thanks for reference. Just wanted to make sure we're on the same page.

lgtm

review: Approve
Revision history for this message
Thierry Carrez (ttx) wrote :

Looks good to me, if this can get reviewed/merged today.

review: Approve (gfe)
Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/ec2/__init__.py'
2--- nova/api/ec2/__init__.py 2011-01-27 22:10:42 +0000
3+++ nova/api/ec2/__init__.py 2011-01-31 22:55:55 +0000
4@@ -171,7 +171,7 @@
5 req.path)
6 # Be explicit for what exceptions are 403, the rest bubble as 500
7 except (exception.NotFound, exception.NotAuthorized) as ex:
8- LOG.audit(_("Authentication Failure: %s"), ex.args[0])
9+ LOG.audit(_("Authentication Failure: %s"), unicode(ex))
10 raise webob.exc.HTTPForbidden()
11
12 # Authenticated!
13@@ -316,30 +316,31 @@
14 try:
15 result = api_request.invoke(context)
16 except exception.InstanceNotFound as ex:
17- LOG.info(_('InstanceNotFound raised: %s'), ex.args[0],
18+ LOG.info(_('InstanceNotFound raised: %s'), unicode(ex),
19 context=context)
20 ec2_id = cloud.id_to_ec2_id(ex.instance_id)
21 message = _('Instance %s not found') % ec2_id
22 return self._error(req, context, type(ex).__name__, message)
23 except exception.VolumeNotFound as ex:
24- LOG.info(_('VolumeNotFound raised: %s'), ex.args[0],
25+ LOG.info(_('VolumeNotFound raised: %s'), unicode(ex),
26 context=context)
27 ec2_id = cloud.id_to_ec2_id(ex.volume_id, 'vol-%08x')
28 message = _('Volume %s not found') % ec2_id
29 return self._error(req, context, type(ex).__name__, message)
30 except exception.NotFound as ex:
31- LOG.info(_('NotFound raised: %s'), ex.args[0], context=context)
32- return self._error(req, context, type(ex).__name__, ex.args[0])
33+ LOG.info(_('NotFound raised: %s'), unicode(ex), context=context)
34+ return self._error(req, context, type(ex).__name__, unicode(ex))
35 except exception.ApiError as ex:
36- LOG.exception(_('ApiError raised: %s'), ex.args[0],
37+ LOG.exception(_('ApiError raised: %s'), unicode(ex),
38 context=context)
39 if ex.code:
40- return self._error(req, context, ex.code, ex.args[0])
41+ return self._error(req, context, ex.code, unicode(ex))
42 else:
43- return self._error(req, context, type(ex).__name__, ex.args[0])
44+ return self._error(req, context, type(ex).__name__,
45+ unicode(ex))
46 except Exception as ex:
47 extra = {'environment': req.environ}
48- LOG.exception(_('Unexpected error raised: %s'), ex.args[0],
49+ LOG.exception(_('Unexpected error raised: %s'), unicode(ex),
50 extra=extra, context=context)
51 return self._error(req,
52 context,
53
54=== modified file 'nova/api/openstack/__init__.py'
55--- nova/api/openstack/__init__.py 2011-01-22 21:20:09 +0000
56+++ nova/api/openstack/__init__.py 2011-01-31 22:55:55 +0000
57@@ -51,8 +51,8 @@
58 try:
59 return req.get_response(self.application)
60 except Exception as ex:
61- LOG.exception(_("Caught error: %s"), str(ex))
62- exc = webob.exc.HTTPInternalServerError(explanation=str(ex))
63+ LOG.exception(_("Caught error: %s"), unicode(ex))
64+ exc = webob.exc.HTTPInternalServerError(explanation=unicode(ex))
65 return faults.Fault(exc)
66
67