can not call str(error), it is not safe for i18n env

Bug #1437125 reported by Haomeng,Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
WSME
Fix Released
Undecided
Lucas Alvares Gomes

Bug Description

For i18n env, the error string is non-english message in unicode format already, so we call str(error) again to encode to unicode again will cause the UnicodeEncodeError.

 File "/usr/lib/python2.7/site-packages/pecan/middleware/debug.py", line 291, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/pecan/middleware/recursive.py", line 56, in __call__
    return self.application(environ, start_response)
  File "/usr/lib/python2.7/site-packages/ironic/api/middleware/parsable_error.py", line 69, in __call__
    app_iter = self.app(environ, replacement_start_response)
  File "/usr/lib/python2.7/site-packages/pecan/core.py", line 805, in __call__
    return super(Pecan, self).__call__(environ, start_response)
  File "/usr/lib/python2.7/site-packages/pecan/core.py", line 654, in __call__
    self.invoke_controller(controller, args, kwargs, state)
  File "/usr/lib/python2.7/site-packages/pecan/core.py", line 554, in invoke_controller
    result = controller(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/wsmeext/pecan.py", line 92, in callfunction
    pecan.conf.get('wsme', {}).get('debug', False)
  File "/usr/lib/python2.7/site-packages/wsme/api.py", line 208, in format_exception
    else str(error)
UnicodeEncodeError: 'ascii' codec can't encode character u'\uff21' in position 3: ordinal not in range(128)

Changed in wsme:
assignee: nobody → Lucas Alvares Gomes (lucasagomes)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to wsme (master)

Fix proposed to branch: master
Review: https://review.openstack.org/175439

Changed in wsme:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to wsme (master)

Reviewed: https://review.openstack.org/175439
Committed: https://git.openstack.org/cgit/stackforge/wsme/commit/?id=81afe37c0efd0d1d00a3885e622b8e8f824de743
Submitter: Jenkins
Branch: master

commit 81afe37c0efd0d1d00a3885e622b8e8f824de743
Author: Lucas Alvares Gomes <email address hidden>
Date: Mon Apr 20 15:57:49 2015 +0100

    Fix i18n when formatting exception

    This patch is also adding the missing tests to the format_exception()
    function since it's related to the fix.

    Change-Id: Id1ab32076e5d112493216dcd92f80fe6e0199237
    Closes-Bug: #1437125

Changed in wsme:
status: In Progress → Fix Committed
Changed in wsme:
milestone: none → 0.8.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.