scripts/logger.py uses unicode strings as oops messages

Bug #700926 reported by Jeroen T. Vermeulen on 2011-01-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
High
Unassigned

Bug Description

I think this is a failure while a logged warning is being registered as an oops, caused by a non-ASCII character in the logged message:

2011-01-10 06:52:34 WARNING Template "hrself" in Groupe S HR congé trunk: can't approve entry 5049083 ('hrself/i18n/nl
_BE.po') because entry 5049091 is in the way.
Traceback (most recent call last):
  File "/srv/launchpad.net/production/launchpad-rev-12161/lib/canonical/launchpad/scripts/logger.py", line 89, in emit
    sys.exc_info(), self.request, informational=informational)
  File "/srv/launchpad.net/production/launchpad-rev-12161/lib/canonical/launchpad/webapp/errorlog.py", line 352, in _raising
    entry = self._makeErrorReport(info, request, now, informational)
  File "/srv/launchpad.net/production/launchpad-rev-12161/lib/canonical/launchpad/webapp/errorlog.py", line 456, in _makeErrorReport
    in self._oops_messages.iteritems())
  File "/srv/launchpad.net/production/launchpad-rev-12161/lib/canonical/launchpad/webapp/errorlog.py", line 455, in <genexpr>
    ('<oops-message-%d>' % key, str(message)) for key, message
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 37: ordinal not in range(128)

This happened in the translations import queue gardener. It did not stop the script from running, but presumably it does hide an oops.

description: updated
Robert Collins (lifeless) wrote :

Ok, so the oops code wants bytestrings - we should have logger.py utf8 encode any unicode strings it has.

summary: - _makeErrorReport fails on non-ASCII error
+ lib/canonical/launchpad/scripts/logger.py passes unicode strings to
+ _raising
Changed in launchpad:
status: New → Triaged
importance: Undecided → High

Or if not logger.py, safe_unicode them.

=== modified file 'lib/lp/services/webapp/errorlog.py'
--- lib/lp/services/webapp/errorlog.py 2012-01-01 02:58:52 +0000
+++ lib/lp/services/webapp/errorlog.py 2012-01-11 21:15:19 +0000
@@ -441,7 +441,7 @@
         # storage for oops messages.
         req_vars = report['req_vars']
         for key, message in self._oops_messages.items():
- req_vars['<oops-message-%d>' % key] = str(message)
+ req_vars['<oops-message-%d>' % key] = safe_unicode(message)

     @contextlib.contextmanager
     def oopsMessage(self, message):

tags: added: trivial
summary: - lib/canonical/launchpad/scripts/logger.py passes unicode strings to
- _raising
+ scripts/logger.py uses unicode strings as oops messages
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers